Skip to content
couryo

Developer guideAutomations

Contacts and events

Contacts with attributes and your app's events through the Couryo API (POST /v1/contacts and POST /v1/events), idempotent, that start and end sequences. No charge per contact.

View as Markdown

A contact is a person who gets your sequences, with attributes to personalize (name, plan, timezone). An event is something that happened in your app (user.signed_up, order.paid): it puts the contact in the sequences that start with that name and ends the ones waiting for it as conversion.

No charge per contact. Having 100 or 100,000 contacts costs the same: only the emails sent count in the plan quota.

Send an event#

cURL
curl https://api.couryo.com/v1/events \
  -H "Authorization: Bearer $COURYO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: signup-ana-1042" \
  -d '{
    "contact": { "email": "ana@example.com", "attributes": { "name": "Ana", "plan": "free" } },
    "name": "user.signed_up",
    "properties": { "source": "site" }
  }'
Response 201
{
  "id": "cev_8k2m4q9w1x7z3abc",
  "contact_id": "con_3n5p7r9t1v2x4zab",
  "name": "user.signed_up",
  "enrolled": [{ "sequence_id": "seq_q8w2e4r6t8y0u1io", "enrollment_id": "enr_a1s3d5f7g9h2j4kl" }],
  "converted": [],
  "created_at": "2026-10-08T18:30:00Z"
}
  • The contact is created or updated by email (attributes are merged into the existing ones).
  • enrolled lists the active sequences this event started. A contact enters a sequence by event once; to put it back, use the manual entry.
  • converted lists the enrollments closed because this is their conversion event.
  • properties are available in the sequence emails as {{event.source}}.
  • Event name: letters, numbers, ., _, : and -, up to 100 characters.
  • Scope: a send (or admin) key. A ck_test_ key puts the contact in test mode: the sequence emails are captured and never delivered.

Idempotency#

Send Idempotency-Key with every event. The same key with the same body returns the same response, with Idempotent-Replayed: true, and creates no other event or enrollment. A different body with the same key returns 409 idempotency_conflict. Beyond the usual 24 hours, the event keeps the key: repeating it later still returns the same event.

Contacts#

Create or update (upsert)
curl https://api.couryo.com/v1/contacts \
  -H "Authorization: Bearer $COURYO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "email": "ana@example.com", "attributes": { "plan": "pro", "city": null } }'
  • Returns 201 when it creates and 200 when it updates.
  • Attributes are plain values (text, number, true or false). null removes the attribute.
  • tags (optional) is a list of lowercase labels, like ["customer", "newsletter"], up to 50 per contact. When sent, it replaces the contact's tags. They drive campaign segments.
  • topics (optional) keeps the contact's topic choices, like { "newsletter": true, "offers": false }. When sent, it is merged into the existing choices.
  • The timezone attribute (for example America/New_York) is used by waits "until HH:mm in the contact's time zone".
  • subscribed is false when the address is on the suppression list for marketing (unsubscribe, bounce, complaint or manual). Unsubscribes always win: the contact gets no marketing sequences, and a running sequence ends right away.
Method and path Scope What it does
POST /v1/contacts send creates or updates by email
GET /v1/contacts read lists, newest first; q searches part of the email, limit and starting_after paginate
GET /v1/contacts/{id} read one contact, by id (con_...) or by email
PATCH /v1/contacts/{id} admin changes the email, the attributes, the tags or the topics
DELETE /v1/contacts/{id} admin deletes the contact and its events; it leaves the sequences (suppression stays)
POST /v1/events send records an event of the contact
POST /v1/contacts/import admin imports contacts from a CSV (see below)
GET /v1/contacts/imports, GET /v1/contacts/imports/{id} read the last 20 imports and the report of one
GET POST /v1/topics, GET PATCH DELETE /v1/topics/{id} read / admin topics of the project

Import from CSV#

In the dashboard, under Contacts > Import CSV: pick the file, see the first rows, tell which column is the email and which is the name, check the other columns that become attributes, choose whether to update existing contacts, the tags and the topics, and confirm the consent. The report shows up right away, with every row left out and why.

Through the API, POST /v1/contacts/import (scope admin) takes the CSV text and answers 202 with the import, which runs in the background:

Import
curl https://api.couryo.com/v1/contacts/import \
  -H "Authorization: Bearer $COURYO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "csv": "Email,Name,City\nana@example.com,Ana,Boston\n",
    "file_name": "customers.csv",
    "mapping": { "email": "Email", "name": "Name", "attributes": { "city": "City" } },
    "update_existing": true,
    "tags": ["customers"],
    "topics": ["newsletter"],
    "consent": true,
    "consent_source": "Newsletter form on the site"
  }'
GET /v1/contacts/imports/{id} when it ends
{
  "id": "imp_4k9w2p7x1abcdefg", "status": "completed", "file_name": "customers.csv",
  "total_rows": 1, "processed_rows": 1, "created": 1, "updated": 0, "skipped": 0, "suppressed": 0,
  "errors": [], "warnings": [], "tags": ["customers"], "topics": ["newsletter"],
  "consent": { "confirmed_at": "2026-10-12T18:30:00.000Z", "source": "Newsletter form on the site" },
  "created_at": "2026-10-12T18:30:00.000Z", "finished_at": "2026-10-12T18:30:01.000Z"
}
  • The file: a first line with the column names; comma, semicolon or tab; up to 10 MB. The names in mapping are the ones on the first line.
  • The name goes to the nome attribute (accounts in Portuguese) or name (accounts in English), the same the ready-made templates use. The other columns become the attributes you map.
  • Existing contacts: with update_existing: true (the default), the file's attributes are merged into the contact's and the tags added to theirs; nothing is removed. With false, the contact stays as it is and the row shows in the report (exists). A topic choice the person made is never overwritten by an import.
  • Left out, with the reason in the report: invalid address (invalid_email), row without an email (missing_email), email repeated in the file (duplicate, the first row counts), role or system address such as abuse@, postmaster@ and noreply@ (role_address) and suppressed address (suppressed): whoever unsubscribed, bounced or complained does not come back through an import.
  • Consent is required: without consent: true the import is refused. The confirmation is kept with the import (when, who and from where), with the source you give in consent_source. People who did not ask to receive complain and hurt delivery for everyone, so the acceptable use policy does not accept bought, rented or scraped lists.
  • Suspicious list: when more than 10% of the rows are invalid, role or suppressed addresses, the report brings a note in warnings. The check before sending a campaign shows how many contacts in the audience never got an email from you.
  • Limits per plan (rows per import and every 24 hours): Free 1,000 and 2,000, Pro 50,000 and 100,000, Scale 200,000 and 400,000, Enterprise 1 million and 2 million. Above that, 403 import_limit_reached.
  • The file is erased as soon as the import ends; only the numbers, the report and the consent record stay.

Topics and preferences#

Topics are the subjects people choose to receive, like a newsletter, product news and offers. With topics, the unsubscribe link of marketing emails opens a preferences page: the person unchecks what they no longer want or leaves every marketing email.

Create a topic
curl https://api.couryo.com/v1/topics \
  -H "Authorization: Bearer $COURYO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "key": "newsletter", "name": "Monthly newsletter", "description": "Once a month", "default": "opt_out" }'
  • default: "opt_out" (the default): every contact is in the topic until they leave. opt_in: only contacts who joined (by you, the API or an import).
  • key is stable and used in audiences and contacts; name and description show on the preferences page. Up to 20 topics per project; visible: false takes a topic off the page.
  • To send a campaign to one topic, use the condition { "field": "topic", "op": "eq", "value": "newsletter" } (neq = whoever is not in it).
  • The preferences page only changes topics. "Leave every marketing email" and the one-click unsubscribe of Gmail and Yahoo (RFC 8058) still remove the person from all marketing, through the suppression list. Opening the link never changes anything: a choice counts only when the person confirms.
  • Without topics in the project, or for an address that is not a contact, the unsubscribe link works as before: a confirmation and leaving all marketing.
  • Transactional emails (password, billing) never depend on topics.
  • Deleting a topic takes it off the page, and campaigns aimed at it reach nobody. People's choices stay saved.

Through MCP#

The track_event (scope send, with idempotency_key) and upsert_contact (scope send) tools do the same through the MCP server, so your AI agent can record sign-ups and purchases. To look things up, list_contacts searches contacts and get_contact returns one contact with its recent events and the sequences it is in (scope read).