Skip to content

Upsert contacts

Request

🔐 Required role: RECD_C

📖 Data dictionary: Contact

Upsert up to 100 contacts, each linked to one or more existing clients, in one request

Send a contacts array (1–100). Each entry upserts a contact (contact_info + contact) and its links to existing clients, all by external reference — no Aiwyn internal ids required.

Partial success. Each contact is processed independently in its own transaction, so one failing contact does not roll back the others. The response splits contacts into succeeded and failed (each keyed by request-order index); the HTTP status is 200 whenever the request itself is valid — inspect the lists for individual outcomes.

Per contact:

  • Matched by pmsRef (contact) and the (contact, client) pair (links); re-sending updates, never duplicates.
  • pmsRef optional: omit to create a native contact (mints AIWYN_<uuid>, not idempotent).
  • clients optional: omit or [] upserts only the contact; unlink via active: false (never by absence).
  • clientRef resolves by the client's pmsRef / clientRef / sysRefs; refs must not contain :.
  • All-or-nothing for that one contact: any unresolved client or stage failure persists nothing for it.

Facade over POST /api/v1/records.

Business Applications:

  • Bulk contact synchronization
  • Link contacts to existing clients

Partial success — one contact's client cannot be resolved:

{
  "contacts": [
    { "pmsRef": "CONTACT-001", "contactInfo": { "firstName": "Jane", "lastName": "Smith" }, "clients": [ { "clientRef": "CLIENT-12345" } ] },
    { "pmsRef": "CONTACT-BAD", "contactInfo": { "firstName": "Ghost", "lastName": "User" }, "clients": [ { "clientRef": "DOES-NOT-EXIST" } ] }
  ]
}

Create native — omit pmsRef to create a new Aiwyn contact (server mints AIWYN_<uuid>):

{
  "contacts": [
    { "contactInfo": { "firstName": "Jane", "lastName": "Smith", "email": "jane.smith@example.com" } }
  ]
}
Security
(BearerAuth and CfAccessClientId and CfAccessClientSecret) or BearerAuth
Bodyapplication/jsonrequired
contactsArray of objectsrequired

Contacts

curl -i -X POST \
  https://api.sandbox.aiwyn.app/api/v1/contacts/upsert \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>' \
  -H 'CF-Access-Client-Id: YOUR_API_KEY_HERE' \
  -H 'CF-Access-Client-Secret: YOUR_API_KEY_HERE' \
  -H 'Content-Type: application/json' \
  -d '{
    "contacts": [
      {
        "pmsRef": "CONTACT-001",
        "contactInfo": {
          "firstName": "Jane",
          "lastName": "Smith",
          "email": "jane.smith@example.com"
        },
        "clients": [
          {
            "clientRef": "CLIENT-12345",
            "relationship": "Primary Contact",
            "receivesInvoice": true
          }
        ]
      },
      {
        "pmsRef": "CONTACT-002",
        "contactInfo": {
          "firstName": "John",
          "lastName": "Doe"
        }
      }
    ]
  }'

Responses

Batch processed; see the succeeded / failed lists

Bodyapplication/json
dataobject
errorobject or null
metaobject
Response
{ "data": { "total": 0, "succeeded": [ … ], "failed": [ … ] }, "error": {}, "meta": { "success": true, "message": "string", "timestamp": "2019-08-24T14:15:22Z", "version": "string" } }