MessageOS
APIContacts

Create or update a contact

POST
/contacts

Creates a contact or updates one. Matches on phoneNumber.

  • A new contact returns 201 and is opted in. An existing contact returns 200 and keeps its opt-in state.
  • A field that is not sent keeps its stored value.
  • attributes are merged, and a key set to null is removed. With replace=true the attributes sent replace the stored ones.
  • timezone must be an IANA zone such as America/New_York.
  • clientId and optedIn are rejected: only a message from the person changes opt-in.

Scope: contacts:write.

Authorization

bearer
headerAuthorizationBearer <mosc_...>

A client key (mosc_).

Query Parameters

replace?boolean

With true, the attributes sent replace the stored attributes of an existing contact. Without it they are merged.

Request Body

application/json
  1. body
phoneNumber*string
externalId?string
displayName?string
timezone?string

A time zone name such as America/New_York.

attributes?
consent?
source?string

Response Body

The contact existed and was updated.

application/json
  1. response
id*integer
phoneNumber*string

The number as stored, in E.164.

optedIn*boolean

true for a new contact. An existing contact keeps its opt-in state.

attributes*

The stored attributes after this write.

Example request

curl -X POST 'https://api.messageos.ai/v1/contacts' \  -H 'Authorization: Bearer mosc_...' \  -H 'Content-Type: application/json' \  -d '{  "phoneNumber": "+15555550123",  "externalId": "crm-881",  "displayName": "Pat Lee",  "timezone": "America/New_York",  "consent": {    "source": "web_form",    "capturedAt": "2026-10-28T23:00:00.000Z"  }}'

Example response

{  "id": 42,  "phoneNumber": "+15555550123",  "optedIn": true,  "attributes": {    "property1": null,    "property2": null  }}