Update a contact
Updates a contact's names, email, source, external_id and custom fields. It never changes who is subscribed.
PATCH /v1/contacts/{id}
Example
curl -X PATCH https://api.wakio.net/v1/contacts/con_7Hq2LpXz4VnBw8tRjG6sYe \
-H "Authorization: Bearer $WAKIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"first_name": "Maya",
"last_name": "Okafor",
"source": "crm",
"external_id": "user_8812",
"fields": {
"plan": "pro"
}
}'
Response 200:
{
"id": "con_7Hq2LpXz4VnBw8tRjG6sYe",
"external_id": "user_8812",
"email": "[email protected]",
"first_name": "Maya",
"last_name": "Okafor",
"source": "signup-form",
"status": "active",
"fields": {
"plan": "pro"
},
"lists": [
{
"id": "lst_5KfN9cDmA3xUvQ2yRhP8Zt",
"status": "subscribed"
}
],
"suppression": null
}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | In the path: the contact's Wakio id, such as con_…, or your own external_id. Escape any / in an external_id as %2F. |
first_name | string | No | First name. An empty string clears it. |
last_name | string | No | Last name. An empty string clears it. |
source | string | No | A free-text label for where the contact came from. An empty string clears it. |
external_id | string | No | Your own id for this person, unique within your account. Do not use an email address: the id appears in request paths and logs. An id that looks like a Wakio contact id (con_ followed by 22 characters) is refused with invalid_contact. An empty string clears it. |
fields | object | No | Values for your custom fields, keyed by field key, such as { "plan": "pro" }. null or an empty string clears a field, so it reads as empty again. A key that is not one of your fields, or a value the field cannot hold, is refused and nothing in the request is saved. |
email | string | No | The person's new address. The contact keeps its lists, consent and history. Their unsubscribes and brand withdrawals follow them to the new address; complaints, bounces and invalid results do not. Answers 409 email_taken when another contact has the address. |
subscribed | boolean | No | Not accepted. Subscribing happens through Add a contact or a signup form. Sending it answers 422 invalid_contact. |
status | string | No | Not accepted. A contact's status follows from what the person did. Sending it answers 422 invalid_contact. |
Response
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The contact's id, such as con_…. |
external_id | string | Yes | Your own id for this person, or null when none is set. |
email | string | Yes | The contact's address. |
first_name | string | Yes | First name, or null. |
last_name | string | Yes | Last name, or null. |
source | string | Yes | The free-text source label, or null. |
status | string | Yes | One of active, unsubscribed, unreachable, or never_subscribed. Only active contacts receive campaigns and flows. |
fields | object | Yes | The contact's custom field values, keyed by field key, such as { "plan": "pro" }. {} when none is set. |
lists | array | Yes | One { "id", "status" } for each list the contact is on or has left. Oldest list first. |
lists[].id | string | Yes | The list's id, such as lst_…. |
lists[].status | string | Yes | subscribed or unsubscribed. |
suppression | object or null | Yes | Why Wakio will not send marketing email to the address, as { "reason", "scope" }, or null when nothing blocks it. |
Errors
Every error this endpoint itself returns is {"error": "<code>"}, sometimes with one more field that explains it. The API overview lists the responses that do not follow that shape.
| Status | Code | What happened | What to do |
|---|---|---|---|
401 | invalid_api_key | The Authorization header is missing, malformed, or names no active key. | Send Authorization: Bearer <key> with an active key from API keys in the dashboard. |
403 | insufficient_scope | The key does not carry the scope this endpoint needs. scope names it. | Issue a key with Can manage contacts ticked under API keys, and use it for this call. |
404 | contact_not_found | No contact in your account has this id. A con_… id is only ever looked up as a Wakio id, never as an external_id. | Check the id, or use the external_id you stored on the contact. |
422 | invalid_contact | A field is unknown, a value does not fit its field, the new email is blank or not an address, the external_id looks like a Wakio contact id, or the request sent subscribed or status. Nothing was saved. detail lists each problem. | Fix each problem detail lists. |
422 | external_id_taken | Another contact in this account already has this external_id. Nothing was saved. external_id echoes it. | Send this person's own id, or leave external_id out. |
409 | email_taken | Another contact in this account already has this email. Nothing was saved. | Erase the other contact if that person is not a real customer, then send the change again. Wakio never merges two contacts, because a merge would destroy the consent record of one of them. |
Notes
Send only what you want to change. A key you leave out keeps its value, and an empty string clears one. In fields, null clears one too, and a cleared field reads as empty, so an audience rule like is empty matches it again. The request is all or nothing: if any field is refused, nothing in it is saved.
A request that carries subscribed or status is refused, whatever the value. Changing who is subscribed is never a side effect of updating a profile.
Changing the email
Send email to move a contact to a new address. It is the same person, so they keep their lists, their consent record and their history.
- Their unsubscribes follow them. If the old address was unsubscribed or on a manual block, the new one is too, and a brand they withdrew from stays withdrawn. Someone who left cannot rejoin by changing address.
- Complaints, bounces and invalid results stay with the old address, because they are about that mailbox.
- A contact who was
unreachableonly because the old address bounced becomesactiveagain if they still have subscribed lists. Anunsubscribedcontact stays unsubscribed, and so does one who unsubscribed before the old address bounced. - If the new address is itself blocked, the contact becomes
unreachableorunsubscribed, as a new contact with that address would. - Campaign and flow email still queued for the contact is canceled, with the reason "email changed" on its delivery. Transactional email is not touched.
- Matching ignores case, so changing only the capitalization is not a conflict.
If another contact in your account already has the address, the call answers 409 email_taken and changes nothing. Wakio does not merge contacts. Erase the other contact if it is not a real customer, then send the change again. If that contact was subscribed, erasing it leaves its opt-out on the address, so the contact you moved is unsubscribed and needs a resubscribe before it can receive campaigns.
This call needs a key with the Can manage contacts scope.