Add or update one contact

POST /api/v1/lists/{listId}/contacts Adds a contact to a list, or completes the one already there — the email address is the key, inside that list. This is the endpoint a funnel or a lead magnet calls: unlike the bulk import, it emits side effects, so an enrolment event fires and a double opt-in confirmation goes out when the call or, failing that, the organization requires one.

Authorization

Role in the organizationThis endpoint
OWNERAllowed
ADMINAllowed
MEMBERRefused — 403
A key carries the role its creator holds in this organization — never a role on AgentsMail itself. See API keys.

Path parameters

ParameterTypeDescription
listIdstringRequired. The list the contact joins. A contact belongs to exactly one

Request body

FieldTypeRequiredDescription
emailstringyesThe upsert key, together with the list. Must be a valid address
firstNamestringnoUp to 100 characters
tagsstring[]noTag names, 1 to 50 characters each. Created in the organization if they do not exist yet
doubleOptInbooleannoApplies to a new contact only. true: created pending, a confirmation email goes out. false: created subscribed, no confirmation email. Omitted: the organization sign-up setting decides
phonestring | nullnoInternational number: leading +, then 8–15 digits, first digit nonzero. Spaces, parentheses, periods and hyphens are removed. Local numbers, 00 prefixes and extensions are rejected; reachability is not checked.
birthDatestring | nullnoReal calendar date YYYY-MM-DD, year 0001–9999, no later than today in UTC. Returned as a date-only string.
localestring | nullnoWell-formed BCP 47 language tag, trimmed and canonicalized (for example fr-fr → fr-FR), up to 100 characters. Not limited to the interface languages.
countrystring | nullnoTwo ASCII letters, trimmed and uppercased (for example fr → FR). Only the shape is checked, not membership in a country-code registry.
customFieldsobjectnoKey → value, up to 50 keys. Each key must be a custom field defined in your organization settings; each value is a string, number, boolean or null, checked against the field's type (see Notes)
overwritebooleannoDefault false: a custom field that already holds a value keeps it, and its key is listed in ignoredCustomFields. true: the value sent replaces it, and null clears it
attributionobjectnoWhere this sign-up came from. Each call that carries a non-empty one adds an entry to the contact's acquisition history (see the table below and Notes)
attribution fields — all optional, strings trimmed:
FieldTypeDescription
utmSourcestringUp to 255 characters
utmMediumstringUp to 255 characters
utmCampaignstringUp to 255 characters
utmContentstringUp to 255 characters
utmTermstringUp to 255 characters
fbclidstringMeta click identifier, up to 500 characters
gclidstringGoogle click identifier, up to 500 characters
referrerstringThe referring page, up to 2048 characters. Not checked as a URL: an app referrer such as android-app://… is accepted
landingUrlstringThe page the visitor landed on, up to 2048 characters
channelstringUp to 50 characters, lowercased. Kept as sent, never refused for its value. Omitted: deduced (see Notes)
extraobjectAny other values you want to keep, up to 20 keys of 50 characters, 4096 characters once serialized
capturedAtstringISO 8601 date-time with a time zone (Z or +01:00). Defaults to the time of the call
json
{
  "email": "ada@example.com",
  "firstName": "Ada",
  "tags": ["vip", "webinar-march"]
}
With custom fields — the first source of a lead, kept on later calls unless overwrite is true:
json
{
  "email": "ada@example.com",
  "customFields": {
    "utm_source": "meta",
    "utm_medium": "paid",
    "utm_campaign": "launch",
    "signup_at": "2026-11-15"
  }
}
With an attribution — the first call creates the contact from a Meta ad, a later call brings it back from YouTube; the contact keeps both entries:
json
{
  "email": "ada@example.com",
  "attribution": {
    "utmSource": "meta",
    "utmMedium": "paid",
    "utmCampaign": "webi-nov-test1",
    "landingUrl": "https://example.com/webinar",
    "capturedAt": "2026-11-01T09:00:00Z"
  }
}
json
{
  "email": "ada@example.com",
  "attribution": {"utmSource": "youtube", "capturedAt": "2026-11-10T18:30:00Z"}
}

Example

bash
curl -X POST -H "x-api-key: $AGENTMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "ada@example.com", "firstName": "Ada", "tags": ["vip"]}' \
  "https://www.agentsmail.io/api/v1/lists/$LIST_ID/contacts"

Response

  • 200 OK — the contact, created or completed. Not 201: the semantics are an upsert, and you cannot tell from the call which of the two happened.
  • 400 Bad Request — invalid profile field, invalid address, a tag over 50 characters, a malformed body; details carries the field-level issues. A key of customFields that is not a custom field of your organization, or a value that does not match its field's type, also answers 400: the error message names every faulty key, and the expected type. Nothing is written — neither the contact nor any of its values. An attribution field over its limit, an extra that is not an object or exceeds its limits, or an invalid capturedAt also answers 400, with details[].path naming the field — for example ["attribution", "utmSource"]. Nothing is written.
  • 401 Unauthorized — missing or invalid key, or its owner left the organization.
  • 403 Forbidden — the key's owner is a member of the organization, not an admin.
  • 404 Not Found — no such list, or it belongs to another organization. The API never confirms that an id exists to a caller who has no right to it.
  • 429 Too Many Requests — over 120 requests in a minute for this key.

Response fields

FieldTypeDescription
successbooleanIndicates if the operation was successful
data.idstringUnique identifier for the contact
data.emailstringIts address — unique inside its list
data.firstNamestring | nullWhat you know of the person
data.lastNamestring | nullNever set by this endpoint; carried from an import or the interface
data.phonestring | nullInternational number: leading +, then 8–15 digits, first digit nonzero. Spaces, parentheses, periods and hyphens are removed. Local numbers, 00 prefixes and extensions are rejected; reachability is not checked.
data.birthDatestring | nullReal calendar date YYYY-MM-DD, year 0001–9999, no later than today in UTC. Returned as a date-only string.
data.localestring | nullWell-formed BCP 47 language tag, trimmed and canonicalized (for example fr-fr → fr-FR), up to 100 characters. Not limited to the interface languages.
data.countrystring | nullTwo ASCII letters, trimmed and uppercased (for example fr → FR). Only the shape is checked, not membership in a country-code registry.
data.statusstringpending, subscribed, unsubscribed, bounced, complained
data.listIdstringThe list it belongs to
data.listobject{id, name} of that list
data.tagsarray{id, name} of every tag carried after the call
data.customFieldsobjectOnly when the call sends customFields. Every custom field value of the contact after the call, by key. Dates come back as ISO strings in UTC
data.ignoredCustomFieldsstring[]Only when the call sends customFields. Keys whose value was kept because the field was already filled and overwrite was not true
data.createdAtstringISO creation date
data.updatedAtstringISO date of the last change

Example response

json
{
  "success": true,
  "data": {
    "id": "4d19…",
    "email": "ada@example.com",
    "firstName": "Ada",
    "lastName": null,
    "phone": null,
    "birthDate": null,
    "locale": null,
    "country": null,
    "status": "subscribed",
    "listId": "0b7c…",
    "list": {"id": "0b7c…", "name": "Newsletter"},
    "tags": [{"id": "7c2e…", "name": "vip"}],
    "createdAt": "2026-08-23T10:22:05.000Z",
    "updatedAt": "2026-08-23T10:22:05.000Z"
  }
}

Agent recipe

Capture email first, retain data.id, then enrich the same contact. Check both responses before reporting success.
js
const base = 'https://www.agentsmail.io/api/v1'
const headers = {'x-api-key': key, 'Content-Type': 'application/json'}
const signup = await fetch(`${base}/lists/${listId}/contacts`, {
  method: 'POST', headers, body: JSON.stringify({email}),
})
if (!signup.ok) throw new Error(await signup.text())
const {data: contact} = await signup.json()
const update = await fetch(`${base}/contacts/${contact.id}`, {
  method: 'PATCH', headers, body: JSON.stringify({phone: '+33612345678'}),
})
if (!update.ok) throw new Error(await update.text())

Notes

  • phone, birthDate, locale and country are optional. Omission preserves an existing value; null clears it. Omitted fields on a new contact are null. Empty strings are rejected.
  • A phone number does not grant permission to send SMS or WhatsApp messages. These profile fields do not change subscription status or consent.
  • An existing contact is completed, never reset. Its status is untouched: someone who unsubscribed stays unsubscribed, whatever this call carries. Putting a contact back to subscribed is an explicit act — see Resubscribe a contact.
  • A contact still pending gets a new confirmation email. When confirmation applies to the call — doubleOptIn: true, or the field omitted while the organization requires confirmation — and the address is already in the list as pending, the call sends a fresh link and the previous one stops working — at most once every 10 minutes per contact. The response is the same as for any other upsert. A subscribed or unsubscribed contact receives nothing. See Sign-up and double opt-in.
  • doubleOptIn comes first, the organization setting otherwise. For a new contact, true means pending with a confirmation email and false means subscribed straight away, without a confirmation email — whatever the organization setting. Omitted, the setting decides: enabled, pending with a confirmation email; disabled, subscribed. The field never changes the status of a contact already in the list.
  • lastName is not accepted here. The single upsert takes firstName only; a full name comes in through Import contacts in bulk or the interface.
  • Tags are added, never replaced: a contact keeps the labels it already carried.
  • Custom fields keep their first value by default. Without overwrite, an empty field is filled and a filled one is kept — its key comes back in ignoredCustomFields. Sending the same value again is not listed. overwrite: true replaces values and lets null clear a field. To change one value unconditionally, Update a contact always overwrites.
  • Custom field types. text: a string, up to 1000 characters. number: a number, or a decimal string such as "12.5". boolean: true, false or their strings. date: YYYY-MM-DD (midnight UTC) or an ISO 8601 date-time with a time zone (Z or +02:00). An empty string counts as null.
  • Each call with an attribution adds one entry; nothing is overwritten. Two calls make two entries. The earliest capturedAt is the contact's first touch, the latest its last touch — so a back-dated capturedAt lands in its right place. A retried call adds a second entry.
  • The entry records how the contact arrived. api when the call created the contact, resubscribe when the address was already in the list. You do not send it.
  • channel is deduced when you omit it, from the first rule that applies: a utmSource of fb, ig, meta or containing facebook / instagram → meta; yt or containing youtube → youtube; adwords or containing google → google; then an fbclid → meta; a gclid → google; a utmMedium of email, e-mail, mail or newsletter → email; a referrer on facebook.com / instagram.com → meta, on youtube.com / youtu.be → youtube, on a google. domain → google; anything else → other. The declared source wins over the click identifier: a YouTube ad bought through Google Ads, with a gclid and utmSource: youtube, is youtube.
  • An empty attribution records nothing. {}, empty strings, an empty extra or a capturedAt alone add no entry.
  • The response does not carry the attribution. With or without it, the call answers the same contact.
  • The bulk import ignores attribution. A key sent on a bulk row is dropped, like any unknown key.
  • A deleted list answers 404. Nothing can enter a list you removed — point the call at a live list, or create one.