Skip to content
Docs menu

Guides

Features

API

Integrations

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

NameTypeRequiredDescription
idstringYesIn the path: the contact's Wakio id, such as con_…, or your own external_id. Escape any / in an external_id as %2F.
first_namestringNoFirst name. An empty string clears it.
last_namestringNoLast name. An empty string clears it.
sourcestringNoA free-text label for where the contact came from. An empty string clears it.
external_idstringNoYour 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.
fieldsobjectNoValues 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.
emailstringNoThe 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.
subscribedbooleanNoNot accepted. Subscribing happens through Add a contact or a signup form. Sending it answers 422 invalid_contact.
statusstringNoNot accepted. A contact's status follows from what the person did. Sending it answers 422 invalid_contact.

Response

NameTypeRequiredDescription
idstringYesThe contact's id, such as con_….
external_idstringYesYour own id for this person, or null when none is set.
emailstringYesThe contact's address.
first_namestringYesFirst name, or null.
last_namestringYesLast name, or null.
sourcestringYesThe free-text source label, or null.
statusstringYesOne of active, unsubscribed, unreachable, or never_subscribed. Only active contacts receive campaigns and flows.
fieldsobjectYesThe contact's custom field values, keyed by field key, such as { "plan": "pro" }. {} when none is set.
listsarrayYesOne { "id", "status" } for each list the contact is on or has left. Oldest list first.
lists[].idstringYesThe list's id, such as lst_….
lists[].statusstringYessubscribed or unsubscribed.
suppressionobject or nullYesWhy 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.

StatusCodeWhat happenedWhat to do
401invalid_api_keyThe Authorization header is missing, malformed, or names no active key.Send Authorization: Bearer <key> with an active key from API keys in the dashboard.
403insufficient_scopeThe 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.
404contact_not_foundNo 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.
422invalid_contactA 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.
422external_id_takenAnother 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.
409email_takenAnother 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 unreachable only because the old address bounced becomes active again if they still have subscribed lists. An unsubscribed contact stays unsubscribed, and so does one who unsubscribed before the old address bounced.
  • If the new address is itself blocked, the contact becomes unreachable or unsubscribed, 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.