APIContacts
Create or update a contact
POST
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.
bearerheader
AuthorizationBearer <mosc_...>A client key (mosc_).
replace?booleanWith true, the attributes sent replace the stored attributes of an existing contact. Without it they are merged.
application/json- body
phoneNumber*stringexternalId?stringdisplayName?stringtimezone?stringA time zone name such as America/New_York.
attributes?consent?source?stringThe contact existed and was updated.
application/json- response
id*integerphoneNumber*stringThe number as stored, in E.164.
optedIn*booleantrue 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 }}