GraphQL API

Contacts

Read and write contacts, and manage the custom fields attached to them

Scopes: CONTACTS_READ to read, CONTACTS_MANAGE to write, CONTACTS_ERASE to erase. Unmasked names, phones, emails and field values additionally need PII_READ.

Contacts are the most PII-dense part of the API. A key without PII_READ still gets rows back, but displayName, phone, email and every field value come back null - and it cannot filter on them either.

contactApi

contactApi(id: ID!): ContactApi

CONTACTS_READ

Reads one contact. Returns null when there is no such contact in the org you are acting on.

Returns ContactApi

FieldTypeDescription
idID!The contact ID.
displayNameStringName as shown in the inbox. Masked without PII_READ.
avatarUrlStringProfile photo. Masked without PII_READ.
phoneStringPhone number. Masked without PII_READ.
emailStringEmail address. Masked without PII_READ.
channels[String!]!Channels this contact has used.
erasedBoolean!true when the contact has been erased on request.
externalIdStringYour identifier for this person, echoed back. Not PII-gated - a masked key still gets it.

ContactApi is a deliberately narrow, API-specific view - not the full internal person record. It uses id, not _id.

contactsApi

contactsApi(filter: ContactApiFilterInput = {}, pagination: ContactApiPaginationInput = {}): ContactApiPage!

CONTACTS_READ

Lists and searches contacts. The operation is expensive. A masked key that filters on search, phone or fields gets a 403.

Arguments

ArgumentTypeDescription
filter.searchStringFree-text search. Requires PII_READ.
filter.externalIdStringYour own identifier.
filter.phoneStringPhone number. Requires PII_READ.
filter.channelContactChannelTELEGRAM, WHATSAPP, VIBER, INSTAGRAM or WEB.
filter.fields[ContactApiFieldFilterInput!]Match custom field values - { key, value }. Requires PII_READ.
filter.createdAfter / createdBeforeDateTimeCreated-date range.
sortDirSortDirectionCreation order. Newest first by default.
pagination.firstIntPage size. Default 20, clamped to 100 for keys.
pagination.afterIDCursor from the previous page - the nextCursor of the last result.

Note that contacts page differently from the rest of the API: first/after, not limit/cursor.

ContactApiPage returns items, nextCursor and totalCount.

A filter that matches more than 10,000 people is refused with a 400 asking you to add another filter. Narrow it rather than paging through everyone on a channel.

Example

query Contacts {
  contactsApi(filter: { search: "alex" }, pagination: { first: 25 }) {
    items { id displayName phone channels }
    nextCursor
  }
}

Keying Contacts on Your Own ID

If you already have users in your own product, you do not need to store Wexio's contact IDs. Pass your own identifier as externalId and Wexio keys the contact on it.

That gives you two ways to work:

ModelHow it works
You keep your own user recordsSend us a channel identity plus your externalId. Your system stays the source of truth.
You have no user recordsUse ours - Wexio's contacts and field definitions become your schema.

externalId is a stable handle: it survives a contact merge, where Wexio's own peopleId does not. It is also returned on contact reads and writes, so the round trip is closed - you can always map a Wexio contact back to your own user without storing our ids.

upsertContactApi

upsertContactApi(input: ContactApiWriteInput!): ContactApi!

CONTACTS_MANAGE

Creates or updates a contact, idempotently keyed on externalId. Two upserts with the same externalId touch one contact - no duplicate, no need to check first.

Arguments - input: ContactApiWriteInput!

FieldTypeDescription
externalIdStringYour identifier for this person. The idempotency key.
displayNameStringName shown in the inbox.
firstName / lastNameStringGiven and family name.
phoneStringPhone number, E.164.
languageStringPreferred language code.
fields[ContactApiFieldInput!]Custom field values as { key, value } - the field's key, not its ID.
channelContactApiChannelInputBind a messaging identity. See below.

Binding a Channel Identity

channel is the part that prevents duplicates. It attaches a channel identity to the contact before that person ever writes to you, so when a real message arrives from that phone or Telegram ID it resolves to the same contact.

ContactApiChannelInput

FieldTypeDescription
kindContactChannelKind!WHATSAPP, TELEGRAM or VIBER.
phoneStringFor WHATSAPP.
telegramIdStringFor TELEGRAM.
viberUserIdStringFor VIBER.
integrationIdStringWhich connected integration. Defaults to the org's integration for that channel, so you can usually omit it.

There is no WEB here - a website-widget identity is created by the visitor, not bound ahead of time.

Example - import a customer from your own system and pre-bind their WhatsApp number:

mutation Upsert {
  upsertContactApi(input: {
    externalId: "crmco-user-88213"
    displayName: "Alex Moreno"
    phone: "+15551234567"
    language: "en"
    fields: [{ key: "customer_tier", value: "gold" }]
    channel: { kind: WHATSAPP, phone: "+15551234567" }
  }) {
    id
    externalId
    displayName
    channels
  }
}

Run the same mutation again with the same externalId and it updates that contact rather than creating a second one.

Without the channel binding, a contact you created by externalId and a person who later messages you from their phone are two separate contacts until someone merges them. Bind the identity at import time and the problem never arises.

contactApiByExternalId

contactApiByExternalId(externalId: String!): ContactApi

CONTACTS_READ

Reads a contact by your identifier. Returns null when no contact carries that externalId.

This is the read that pairs with upsertContactApi - you never have to store Wexio's IDs on your side.

query ByMyId {
  contactApiByExternalId(externalId: "crmco-user-88213") {
    id
    externalId
    displayName
    phone
    channels
  }
}

Identity fields come back null without PII_READ, exactly as on the other contact reads - so a key that can import people cannot necessarily read their phone numbers back.

externalId is the exception: it is your identifier, not the person's PII, so it is returned even to a masked key. That is what makes the round trip work without PII_READ - you can always tell which of your users a contact corresponds to.

createContactApi / updateContactApi

createContactApi(input: ContactApiWriteInput!): ContactApi!
updateContactApi(id: ID!, input: ContactApiWriteInput!): ContactApi!

CONTACTS_MANAGE

Prefer upsertContactApi when you have your own identifier for the person - one idempotent call replaces "read, then create or update", and repeating it is safe. Use createContactApi / updateContactApi when you are addressing a contact by Wexio's own id.

ContactApiWriteInput

FieldTypeDescription
displayNameStringName shown in the inbox.
firstNameStringGiven name.
lastNameStringFamily name.
phoneStringPhone number, E.164.
languageStringPreferred language code.
fields[ContactApiFieldInput!]Custom field values to set in the same call. Each entry is { key: String!, value: JSON } - the field's key, not its ID.

Example

mutation Upsert {
  createContactApi(input: {
    displayName: "Alex Moreno"
    firstName: "Alex"
    lastName: "Moreno"
    phone: "+15551234567"
    language: "en"
    fields: [{ key: "customer_tier", value: "gold" }]
  }) { id displayName }
}

The returned DTO is masked unless the key also holds PII_READ - so a write-only key gets back null for the very values it just set. That is expected.

Custom Fields

Wexio contacts carry custom fields in two layers: a definition (the field itself - name, type, options) and a value per contact.

Definitions

getPeopleFieldDefinitions(filter: PeopleFieldsFilterDto): [PeopleFieldDefinition!]!   # CONTACTS_READ
createPeopleFieldDefinition(input: CreateFieldDefinitionDto!): PeopleFieldDefinition! # CONTACTS_MANAGE
updatePeopleFieldDefinition(id: String!, input: UpdateFieldDefinitionDto!): PeopleFieldDefinition! # CONTACTS_MANAGE
deletePeopleFieldDefinition(id: String!): Boolean!                                    # CONTACTS_MANAGE

Keys manage CUSTOM fields only. A key cannot create, modify or delete the built-in fields Wexio ships, and setPeopleFieldValue rejects a system field outright - even with CONTACTS_MANAGE. You manage only the fields your org defined.

Values

getPeopleFieldValues(peopleId: String!, filter: PeopleFieldsFilterDto): [PeopleFieldValue!]!  # CONTACTS_READ
getPeopleFieldValue(id: String!): PeopleFieldValue!                                           # CONTACTS_READ
setPeopleFieldValue(input: SetFieldValueDto!): PeopleFieldValue!                              # CONTACTS_MANAGE
deletePeopleFieldValue(peopleId: String!, fieldId: String!): Boolean!                         # CONTACTS_MANAGE

SetFieldValueDto

FieldTypeRequiredDescription
peopleIdString!YesThe contact.
fieldIdString!YesThe field definition.
valueJSONNoThe value. Omit or pass null to clear it.

Example

mutation SetTier {
  setPeopleFieldValue(input: {
    peopleId: "6804f4d5a6f9f35f6e66f1a2"
    fieldId: "6805c1a0b4d5e6f70123ab45"
    value: "gold"
  }) { _id value }
}

Field values are person PII: a key without PII_READ gets them masked on read, even values it set itself.

Erasure

Erasing a contact is permanent and needs the separate CONTACTS_ERASE scope. See Contact Erasure for previewErase and eraseContact.

Names from WhatsApp

A contact's WhatsApp profile name is used only to fill a gap. It replaces an empty name, or one that is only the phone number - it never overwrites a name set by you or by an operator.

So a name you import survives, and a contact you created without one stops reading as a bare number once they message. You do not have to choose between the two.

isWhatsAppIdEditable

isWhatsAppIdEditable(peopleId: String!): Boolean!

CONTACTS_READ

Whether this contact's WhatsApp identity can still be changed. Check it before offering an edit - a contact with live WhatsApp history is locked.

A Note on IDs

Two different identifiers appear here, and mixing them is the easiest mistake to make:

IDUsed by
ContactApi.idcontactApi, updateContactApi
externalId (yours)upsertContactApi, contactApiByExternalId - survives merges
field keythe fields array on a contact write
peopleIdthe people-field operations, and ContactPayload.peopleId on webhooks

Webhook payloads also carry contactId - the merge-winner ID. Key your own records on that if you want contact merges to reconcile cleanly.

Was this page helpful?

On this page