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 organization | This endpoint |
|---|---|
OWNER | Allowed |
ADMIN | Allowed |
MEMBER | Refused — 403 |
Path parameters
| Parameter | Type | Description |
|---|---|---|
listId | string | Required. The list the contact joins. A contact belongs to exactly one |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
email | string | yes | The upsert key, together with the list. Must be a valid address |
firstName | string | no | Up to 100 characters |
tags | string[] | no | Tag names, 1 to 50 characters each. Created in the organization if they do not exist yet |
doubleOptIn | boolean | no | Applies 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 |
phone | string | null | no | International 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. |
birthDate | string | null | no | Real calendar date YYYY-MM-DD, year 0001–9999, no later than today in UTC. Returned as a date-only string. |
locale | string | null | no | Well-formed BCP 47 language tag, trimmed and canonicalized (for example fr-fr → fr-FR), up to 100 characters. Not limited to the interface languages. |
country | string | null | no | Two ASCII letters, trimmed and uppercased (for example fr → FR). Only the shape is checked, not membership in a country-code registry. |
customFields | object | no | Key → 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) |
overwrite | boolean | no | Default 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 |
attribution | object | no | Where 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:
| Field | Type | Description |
|---|---|---|
utmSource | string | Up to 255 characters |
utmMedium | string | Up to 255 characters |
utmCampaign | string | Up to 255 characters |
utmContent | string | Up to 255 characters |
utmTerm | string | Up to 255 characters |
fbclid | string | Meta click identifier, up to 500 characters |
gclid | string | Google click identifier, up to 500 characters |
referrer | string | The referring page, up to 2048 characters. Not checked as a URL: an app referrer such as android-app://… is accepted |
landingUrl | string | The page the visitor landed on, up to 2048 characters |
channel | string | Up to 50 characters, lowercased. Kept as sent, never refused for its value. Omitted: deduced (see Notes) |
extra | object | Any other values you want to keep, up to 20 keys of 50 characters, 4096 characters once serialized |
capturedAt | string | ISO 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"]
}overwrite is true:
json
{
"email": "ada@example.com",
"customFields": {
"utm_source": "meta",
"utm_medium": "paid",
"utm_campaign": "launch",
"signup_at": "2026-11-15"
}
}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. Not201: 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;detailscarries the field-level issues. A key ofcustomFieldsthat is not a custom field of your organization, or a value that does not match its field's type, also answers400: theerrormessage names every faulty key, and the expected type. Nothing is written — neither the contact nor any of its values. Anattributionfield over its limit, anextrathat is not an object or exceeds its limits, or an invalidcapturedAtalso answers400, withdetails[].pathnaming 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 amemberof the organization, not anadmin.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
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the operation was successful |
data.id | string | Unique identifier for the contact |
data.email | string | Its address — unique inside its list |
data.firstName | string | null | What you know of the person |
data.lastName | string | null | Never set by this endpoint; carried from an import or the interface |
data.phone | string | null | International 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.birthDate | string | null | Real calendar date YYYY-MM-DD, year 0001–9999, no later than today in UTC. Returned as a date-only string. |
data.locale | string | null | Well-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.country | string | null | Two ASCII letters, trimmed and uppercased (for example fr → FR). Only the shape is checked, not membership in a country-code registry. |
data.status | string | pending, subscribed, unsubscribed, bounced, complained |
data.listId | string | The list it belongs to |
data.list | object | {id, name} of that list |
data.tags | array | {id, name} of every tag carried after the call |
data.customFields | object | Only 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.ignoredCustomFields | string[] | Only when the call sends customFields. Keys whose value was kept because the field was already filled and overwrite was not true |
data.createdAt | string | ISO creation date |
data.updatedAt | string | ISO 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, retaindata.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,localeandcountryare optional. Omission preserves an existing value;nullclears it. Omitted fields on a new contact arenull. 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
statusis untouched: someone who unsubscribed stays unsubscribed, whatever this call carries. Putting a contact back tosubscribedis an explicit act — see Resubscribe a contact. -
A contact still
pendinggets 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 aspending, 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. Asubscribedorunsubscribedcontact receives nothing. See Sign-up and double opt-in. -
doubleOptIncomes first, the organization setting otherwise. For a new contact,truemeanspendingwith a confirmation email andfalsemeanssubscribedstraight away, without a confirmation email — whatever the organization setting. Omitted, the setting decides: enabled,pendingwith a confirmation email; disabled,subscribed. The field never changes the status of a contact already in the list. -
lastNameis not accepted here. The single upsert takesfirstNameonly; 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 inignoredCustomFields. Sending the same value again is not listed.overwrite: truereplaces values and letsnullclear 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,falseor their strings.date:YYYY-MM-DD(midnight UTC) or an ISO 8601 date-time with a time zone (Zor+02:00). An empty string counts asnull. -
Each call with an
attributionadds one entry; nothing is overwritten. Two calls make two entries. The earliestcapturedAtis the contact's first touch, the latest its last touch — so a back-datedcapturedAtlands in its right place. A retried call adds a second entry. -
The entry records how the contact arrived.
apiwhen the call created the contact,resubscribewhen the address was already in the list. You do not send it. -
channelis deduced when you omit it, from the first rule that applies: autmSourceoffb,ig,metaor containingfacebook/instagram→meta;ytor containingyoutube→youtube;adwordsor containinggoogle→google; then anfbclid→meta; agclid→google; autmMediumofemail,e-mail,mailornewsletter→email; a referrer onfacebook.com/instagram.com→meta, onyoutube.com/youtu.be→youtube, on agoogle.domain →google; anything else →other. The declared source wins over the click identifier: a YouTube ad bought through Google Ads, with agclidandutmSource: youtube, isyoutube. -
An empty
attributionrecords nothing.{}, empty strings, an emptyextraor acapturedAtalone 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.