Contacts are the people your broadcasts go to: an address, names, your own attributes, and where the person agreed to get email from you. Lists group them, and a broadcast goes to one or more lists. Add contacts one at a time from your app, up to 1,000 per call, or from a CSV file.
In the dashboard: Contacts, with Lists and Imports tabs.
Base URL: https://api.groundmail.dev
Auth:
Reading contacts, lists and imports needs the contacts:read scope; adding, changing and deleting them needs contacts:write. broadcasts:write can read them too.
A test API key writes the same contacts and lists as a live key. There is one list of people. A broadcast you start later with a live key includes them. To try a send without delivering it, start the broadcast with the test key.
Authorization: Bearer gm_...Add a contact
consent_source is required: where this person agreed to get email from you, such as signup_form or checkout. consent_at (ISO 8601) says when, and defaults to now. Both are kept with the contact and can't be changed later.
If the address is already a contact, POST /contacts updates it and answers 200 instead of 201. Fields you leave out keep their values, and attributes are merged into the ones it has. So calling it on every sign-up or plan change is safe. If the merge would take the contact past 50 attributes or 4,096 characters, nothing is changed and you get a 400 validation_error: send "attributes": null with PATCH to clear them first. A contact that is already over the limits can still take changes that add no keys and don't make its attributes longer.
| Field | |
|---|---|
email |
Required. |
consent_source |
Required. Up to 200 characters. |
consent_at |
When they agreed. Can't be in the future. |
first_name, last_name |
Up to 200 characters. |
external_id |
Your id for this person, to find them with GET /. |
attributes |
Your own fields: up to 50 keys (letters, digits and underscores, starting with a letter or underscore), each a string up to 1,000 characters, a number, a boolean or null. At most 4,096 characters as JSON. The limits are for all of a contact's attributes, after yours are merged into the ones it has. |
The response is the contact:
const contact = await groundmail.contacts.create({
email: 'ada@example.com',
first_name: 'Ada',
consent_source: 'signup_form',
attributes: { plan: 'pro', seats: 3 },
})curl -X POST https://api.groundmail.dev/contacts \
-H "Authorization: Bearer $GROUNDMAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"ada@example.com","first_name":"Ada","consent_source":"signup_form","attributes":{"plan":"pro"}}'{
"contact": {
"id": "5a6b7c8d-1e2f-4a3b-9c4d-5e6f7a8b9c0d",
"email": "ada@example.com",
"external_id": null,
"first_name": "Ada",
"last_name": null,
"attributes": { "plan": "pro", "seats": 3 },
"status": "subscribed",
"consent": { "source": "signup_form", "at": "2026-12-01T10:00:00.000Z" },
"source": "api",
"created_at": "2026-12-01T10:00:00.000Z",
"updated_at": "2026-12-01T10:00:00.000Z"
}
}Status
status is never stored. It's read live from your suppressions and newsletter opt-outs each time you read a contact:
status |
Means | Gets broadcasts |
|---|---|---|
subscribed |
Nothing stops email to them. | Yes |
unsubscribed |
They unsubscribed from a broadcast, opted out of newsletter or product email, or you suppressed them. | No |
bounced |
Their address bounced. | No |
complained |
They marked your email as spam. | No |
So someone who unsubscribes stays unsubscribed, even if you delete the contact and add the address again. To email them again, they have to opt in again and you remove their opt-out.
Add many at once
POST /contacts/batch takes up to 1,000 contacts. A top-level consent_source fills rows that don't have their own:
A row that fails validation, or whose attributes would go over the limits once merged into the contact's, is listed in errors by its index, and the rest still go in. Existing addresses are updated as in POST /contacts.
const result = await groundmail.contacts.batch({
consent_source: 'signup_form',
contacts: users.map((user) => ({ email: user.email, first_name: user.name, external_id: user.id })),
})
// { created: 998, updated: 1, errors: [{ index: 412, message: '`email` must be a valid email address' }] }Import a CSV file
Send the file itself as the body, with Content-Type: text/csv:
The file is UTF-8 CSV up to 20 MB (about 200,000 rows), with a header row. An email column is required (email_address works too). first_name, last_name and external_id fill those fields, and every other column becomes an attribute. Its name is the header in lowercase, with anything other than letters, digits and underscores turned into _ (Plan Name becomes plan_name). A name that would start with a digit gets a _ in front, because an attribute key has to start with a letter or underscore (2FA becomes _2fa, used as {{contact.attributes._2fa}}). An empty cell leaves the existing value as it is. Each new contact's consent time is the time of the import. consent_source (required) goes on each new contact, and list adds every imported contact to that list.
The import answers 202 at once and adds the rows in the background. Follow it with GET /contacts/imports/{id}:
status goes queued, running, then succeeded, failed or cancelled. row_errors lists the first 100 rows that were left out, by their line in the file. At most 3 imports run at once per workspace; POST /contacts/imports/{id}/cancel stops one, and contacts already added stay. GET /contacts/imports lists the last 30 days of imports. The file itself is deleted once the import finishes.
curl -X POST "https://api.groundmail.dev/contacts/imports?consent_source=signup_form&list=newsletter&filename=users.csv" \
-H "Authorization: Bearer $GROUNDMAIL_API_KEY" \
-H "Content-Type: text/csv" \
--data-binary @users.csvimport { readFile } from 'node:fs/promises'
const csv = await readFile('users.csv')
const started = await groundmail.contacts.imports.create(csv, { consent_source: 'signup_form', list: 'newsletter' })groundmail contacts import users.csv --consent signup_form --list newsletter --wait{
"import": {
"id": "8c1d…",
"status": "succeeded",
"filename": "users.csv",
"rows": { "processed": 1200, "created": 1150, "updated": 46, "invalid": 4 },
"row_errors": [{ "row": 17, "message": "`email` must be a valid email address" }],
"failure_message": null
}
}List, get, update and delete
PATCH changes only what you send. null clears a name or external_id. attributes are merged; "attributes": null clears them all. The address and consent can't change: delete the contact and add it again.
Deleting a contact takes it off every list. Their unsubscribes, bounces and complaints stay on record.
Lists of contacts are paged: pass next_cursor back as cursor while has_more is true.
GET /contacts?list=newsletter&limit=50 # newest first; also ?email= and ?external_id=
GET /contacts/{id}
PATCH /contacts/{id} # names, external_id, attributes
DELETE /contacts/{id}Lists
A list's key is made from its name when it's created and never changes, so use it in code: anywhere a list is named, its key or its id works. Renaming a list (PATCH /lists/{id}) keeps the key.
POST /lists/{id}/contacts adds existing contacts, up to 1,000 per call. Ones already on the list are skipped. Addresses and ids that aren't contacts come back in not_found, so a retry is safe:
A workspace can have up to 1,000 lists. Past that, POST /lists answers 409: delete lists you no longer use, or tell contacts apart with attributes.
const list = await groundmail.lists.create({ name: 'Beta users' }) // key: 'beta-users'
await groundmail.lists.addContacts('beta-users', { emails: ['ada@example.com', 'grace@example.com'] })GET /lists # newest first, with contact_count
POST /lists # { "name": "Beta users", "description": "…" }
GET /lists/{id}
PATCH /lists/{id}
DELETE /lists/{id} # its contacts stay
GET /lists/{id}/contacts
POST /lists/{id}/contacts # { "emails": [...] } or { "contact_ids": [...] }
DELETE /lists/{id}/contacts/{contact_id} # the contact stays{ "added": 1, "not_found": { "contact_ids": [], "emails": ["nobody@example.com"] } }Errors
| Status | Code | When |
|---|---|---|
400 |
validation_error |
A field is missing or invalid, the CSV isn't UTF-8, or a batch has more than 1,000 contacts. |
404 |
not_found |
No contact, list or import with that id or key in this workspace. |
409 |
conflict |
A list with that name exists, the workspace has 1,000 lists, or 3 imports are already running. |
413 |
validation_error |
A request over 20 MB, or a CSV file over 20 MB. A full batch of 1,000 contacts fits as plain UTF-8; if your JSON library escapes non-ASCII characters (Python's json.dumps does unless you pass ensure_ascii=False), a batch of long non-Latin names and attributes can go over, so send fewer contacts per request. |
In the CLI and MCP
The MCP server has list_contacts, add_contact, add_contacts, import_contacts_csv and the list tools.
groundmail contacts add ada@example.com --consent signup_form --first-name Ada --attr plan=pro
groundmail contacts list --list newsletter
groundmail lists create --name "Beta users"
groundmail lists add beta-users --emails ada@example.com,grace@example.com