# Sending for your customers

If your software sends letters for businesses of its own (a lettings platform for its agents, say), Atomside keeps each of them as a customer: its own sender, its own limits, its own approvals by its own people, and its own line in your usage. This guide walks through one customer from start to finish, in test mode. Every request and answer below was made against the API; ids, links and times are replaced with stand-ins, and long answers are cut down to the fields that matter here.

The calls in this guide are REST, the [CLI](cli.md) and the [SDK](sdk.md) only. They are not MCP tools: they are for your own software, not for an agent to read.

## 1. Two keys

Managing customers needs the scope **Manage customers** (`customers:manage`). Sending needs `letters:send`.

- **In test mode** one key may hold both. First run makes one like that, so you can try everything with one key.
- **In live mode** a key cannot hold both: making one is refused `scopes_not_valid`. Make one key for your sending code and one for your account code. With both on one key, one leaked credential could send a letter, make an approval link to an inbox it controls, and approve it.

A person makes keys in the console under Developers, API keys. Tick "Manage customers" for the second key. Connected assistants (OAuth) never get `customers:manage`.

```sh
export ATOMSIDE_SEND_KEY=as_test_…
export ATOMSIDE_MANAGE_KEY=as_test_…   # in test, this may be the same key
```

## 2. Add a customer

`relationship` says how the customer stands to you:

- `own_letters`: the letters are the customer's own, from its own name and return address. We post a code to that address to check it.
- `platform_name`: the letters go out in your name, from your verified sender. Nothing is posted to the customer.

```sh
curl -X POST https://api.atomside.com/v1/customers \
  -H "Authorization: Bearer $ATOMSIDE_MANAGE_KEY" \
  -H "Idempotency-Key: add-cust_4471" \
  -H "Content-Type: application/json" \
  -d '{
    "ref": "cust_4471",
    "name": "Acme Lettings",
    "relationship": "own_letters",
    "sender": { "name": "Acme Lettings Ltd", "line1": "Flat 1", "line2": "2 Example Street", "town": "Sampleford", "postcode": "XX2 2XX" },
    "contact_email": "office@acmelettings.example",
    "limits": { "per_day_letters": 50, "per_month_letters": 1000 }
  }'
```

The answer (HTTP 200, cut down):

```json
{
  "id": "cus_example000000001",
  "ref": "cust_4471",
  "name": "Acme Lettings",
  "relationship": "own_letters",
  "state": "waiting_on_sender",
  "until_verified": "hold",
  "sender": {
    "state": "code_posted",
    "name": "Acme Lettings Ltd",
    "address_line": "Flat 1, 2 Example Street, Sampleford, XX2 2XX",
    "posted_at": "2026-11-16T09:30:00.000Z",
    "expires_at": "2026-12-16T09:30:00.000Z",
    "attempts_left": 5,
    "letters_sent": 1,
    "verified_at": null
  },
  "limits": {
    "per_day_letters": 50,
    "per_month_letters": 1000,
    "over_limit": "ask",
    "applies": ["50 letters a day", "1,000 letters a month"]
  },
  "held_letters": 0,
  "created_via": "api"
}
```

`ref` is your own id for the customer. It is never printed, it must not be an email address, and it can never be used for another customer. A ref a letter already named (through `on_behalf_of`) is declared instead, keeping its letters.

Webhook: `customer.sender_code_posted`, with the customer's id, ref and name, `posted_at`, `expires_at` and `letters_sent`.

## 3. The code letter

We post the customer a letter with a six-digit code and a link to a page (`/c/…`) where it types the code in. The letter and the page carry your brand. In live mode allow three working days. In test mode the code letter counts as posted at once and the code is `000000`.

Your support staff can also type a code a customer gives them, with `confirm_customer_sender`. A wrong code says how many tries are left; after five a new code is posted, up to three letters. `resend_customer_sender_code` posts a new code when the first has not arrived (the old one stops working).

## 4. A letter for the customer, kept until the code is in

Name the customer on the quote with `on_behalf_of`:

```sh
curl -X POST https://api.atomside.com/v1/quotes \
  -H "Authorization: Bearer $ATOMSIDE_SEND_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": { "name": "Ms D. Example", "line1": "14 Specimen Road", "town": "Exampleton", "postcode": "XX1 1XX" },
    "pages": [{ "text": "Dear Ms Example,\n\nYour rent of £850.00 is due on 1 December.\n\nYours sincerely,\nAcme Lettings", "format": "markdown" }],
    "on_behalf_of": { "ref": "cust_4471" },
    "reference": "job-88213"
  }'
```

The quote says whose sender prints and what sending would do (cut down):

```json
{
  "quote": "qt_example000000001",
  "price": { "credits": 15, "gbp": "1.50" },
  "sha256": "d0cd295e1a893c0135041a4ef3e93b07fdfc611ff38d6287c722edc7b3ccd94d",
  "sender": { "name": "Acme Lettings Ltd", "of": "customer", "verified": false },
  "on_send": "waits_for_approval",
  "on_send_reason": "customer_sender_unverified",
  "on_send_says": "1 page on 1 sheet, both sides. 15 credits (£1.50) if quoted now. We charge by the sheet. It would be kept, and nothing charged, until the customer enters the code from the letter we post to it. Then it waits for a person: Every letter from acme-platform waits for a person."
}
```

The agent in this example asks a person for every letter, so the quote says both things: the letter is kept until the code is in, and then it waits for a person. Keeping a letter never skips another rule: a limit that refuses still refuses at send.

Send it:

```sh
curl -X POST https://api.atomside.com/v1/letters \
  -H "Authorization: Bearer $ATOMSIDE_SEND_KEY" \
  -H "Idempotency-Key: job-88213" \
  -H "Content-Type: application/json" \
  -d '{ "quote": "qt_example000000001" }'
```

The answer is a "not yet" (HTTP 202, cut down). The letter exists: do not send it again.

```json
{
  "answer": "not_yet",
  "code": "customer_sender_unverified",
  "fixed_by": "person",
  "say": "This letter is kept. It goes when Acme Lettings enters the code from the letter we posted to them.",
  "money": { "say": "Nothing was charged." },
  "retry": "not_needed",
  "letter": "ltr_example000000001",
  "details": {
    "customer": "Acme Lettings",
    "letter": "ltr_example000000001",
    "sender_state": "code_posted"
  },
  "docs": "https://api.atomside.com/docs/refusals/customer_sender_unverified"
}
```

`get_letter` shows it as `held`:

```json
{
  "letter": "ltr_example000000001",
  "status": "held",
  "says": "This letter is kept until Acme Lettings enters the code from the letter we posted to them. Nothing is charged while it waits. Once the code is in, it waits for a person to approve it. If the code is not entered by 09:30 on Wed 16 Dec it lapses.",
  "waiting_reason": "customer_sender",
  "fixed_by": "person",
  "customer": { "ref": "cust_4471", "name": "Acme Lettings" },
  "next": "Do not send it again. It goes when Acme Lettings enters the code from the letter we posted to them, or when your software passes that code to confirm_customer_sender. In test mode the code is 000000."
}
```

`waiting_reason` is what it waits for now: the code, not the approval that comes after it. `fixed_by: person` says someone on your side moves it on, as in a refusal. `advance_test_letter` cannot move it.

Webhooks: `letter.quoted`, then `letter.held` with `"reason": "customer_sender"`, `lapses_at` and `"on_behalf_of": "cust_4471"`.

If you would rather such letters went from your own sender until the code is in, set `until_verified` to `platform_sender` with `update_customer`.

## 5. The customer enters the code

Here support staff type the code for the customer:

```sh
curl -X POST https://api.atomside.com/v1/customers/cust_4471/sender/confirm \
  -H "Authorization: Bearer $ATOMSIDE_MANAGE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "code": "000000" }'
```

The answer (HTTP 200, cut down):

```json
{
  "ref": "cust_4471",
  "state": "sending",
  "sender": {
    "state": "verified",
    "name": "Acme Lettings Ltd",
    "address_line": "Flat 1, 2 Example Street, Sampleford, XX2 2XX",
    "verified_at": "2026-11-16T09:30:00.000Z"
  },
  "held_letters": 0,
  "released_letters": 1
}
```

The kept letter goes on, through every rule as if it had just been sent. Here it now waits for a person.

Webhooks: `customer.sender_verified` (`"via": "api"`, `"released_letters": 1`), then `letter.waiting_for_approval`. Its `approval` carries the id you need for the next step:

```json
{
  "letter": "ltr_example000000001",
  "state": "waiting_for_approval",
  "reason": "asks_every_time",
  "previous_state": "held",
  "approval": {
    "id": "apr_example000000001",
    "url": "https://app.atomside.com/a/…",
    "covers": "d0cd295e1a893c0135041a4ef3e93b07fdfc611ff38d6287c722edc7b3ccd94d",
    "expires_at": "2026-11-18T09:30:00.000Z"
  },
  "on_behalf_of": "cust_4471"
}
```

When a send waits for a person straight away (the sender was already verified), the same id is in the send answer, at `details.approval.by_link.approval`. And whenever a letter waits, `get_letter` has it too, so the letter alone is enough (cut down):

```json
{
  "letter": "ltr_example000000001",
  "status": "waiting_for_approval",
  "fixed_by": "person",
  "approval": {
    "id": "apr_example000000001",
    "status": "waiting",
    "by_link": { "approval": "apr_example000000001", "make_with": "create_approval_link" }
  }
}
```

`approval.by_link` is there while the letter waits and a person at its customer approves it by a link (section 6); otherwise it is null. `list_letters` carries the same `approval: { id, status, by_link }` on each letter, and `wait_for_approval` carries `approval` and `by_link`.

## 6. Approval by the customer's own user

An owner turns this on in the console under Organisation, Brand and approvals: "Who approves a customer's letters" set to the customer's own user, by a link. The same page sets your brand name, help email, logo, button colour, how long a link lasts (4, 24 or 72 hours) and who emails it (Atomside, or you).

Then make a link for the person at the customer who should decide:

```sh
curl -X POST https://api.atomside.com/v1/approvals/apr_example000000001/links \
  -H "Authorization: Bearer $ATOMSIDE_MANAGE_KEY" \
  -H "Idempotency-Key: link-apr_example000000001-user_4471" \
  -H "Content-Type: application/json" \
  -d '{ "approver_email": "j.sample@acmelettings.example", "approver_name": "J. Sample", "approver_ref": "user_4471" }'
```

```json
{
  "id": "apl_example000000001",
  "url": "https://app.atomside.com/l/…",
  "expires_at": "2026-11-17T09:30:00.000Z",
  "emailed": true
}
```

With "Atomside sends it" we email the link in your brand; otherwise show `url` yourself. The `Idempotency-Key` is required: a retry with the same key gives the same link and sends no second email, and the same key with another approver is refused `idempotency_key_reused`. We keep only the link's id against the key, never the url, and make the url again on a retry; if the link has been used, revoked or has run out by then, the retry is refused `approval_link_gone`: read the letter, and if it still waits make a new link with a new key. Asking again for the same approval and approver with a new key also gives the same link while it works.

The page at the link shows the letter as it will print. The person proves they hold the inbox with a six-digit code we email when they open it, then approves or declines (a note is needed to decline). In test mode the code is `000000` and no code email is sent. A link works for one decision. Your own team is not emailed for a customer's letters while link approval is on; they still see them under Approvals and may decide there.

`wait_for_approval` then answers:

```json
{
  "letter": "ltr_example000000001",
  "status": "approved",
  "letter_status": "queued",
  "via": "link",
  "by": "J. Sample, by a link",
  "covers": "sha256 d0cd295e1a893c0135041a4ef3e93b07fdfc611ff38d6287c722edc7b3ccd94d",
  "approval": "apr_example000000001",
  "by_link": null,
  "charged": { "credits": 0, "gbp": "0.00" },
  "money": {
    "held": { "credits": 15, "gbp": "1.50" },
    "charged": { "credits": 0, "gbp": "0.00" },
    "returned": { "credits": 0, "gbp": "0.00" },
    "say": "15 credits (£1.50) are held now and charged when it is posted."
  },
  "says": "Approved at 09:30. It is posted on Mon 16 Nov."
}
```

The credits were held when the letter was sent and are charged when it is posted; until then `charged` is 0. Once it is posted, `wait_for_approval` says `"charged": { "credits": 15, … }` and "15 credits (£1.50) were charged.", whoever approved it.

Webhook: `letter.approved`, with `posts_on` and `cancel_until`.

## 7. Posted, and the record names the customer

In test mode move the letter on with `advance_test_letter`: `letter.printing`, `letter.printed`, `letter.posted`, then `letter.on_record`, the same events a live letter sends. `get_letter` then shows (cut down):

```json
{
  "status": "on_record",
  "customer": { "ref": "cust_4471", "name": "Acme Lettings" },
  "approval": { "status": "approved", "decided_by": "J. Sample, by a link", "via": "link" },
  "money": {
    "charged": { "credits": 15, "gbp": "1.50" },
    "say": "15 credits (£1.50) were charged."
  },
  "record": {
    "id": "rec_example000000001",
    "url": "https://app.atomside.com/r/…",
    "sha256": "2a35816c18bb3df3afeb3bbd4efb1b4282f0e212f8061961d582231f1aff7748",
    "signed": false
  }
}
```

A test record is not signed. A live record (document version 3) names the sender it printed from (`sender.of` is `customer`), who it was sent through (your account), and the customer and the approver as sealed commitments: the record proves which customer it was for, and who approved it, without putting their names in a public file. The console's record page downloads `customer.json` and `approver.json`, the openings of those commitments, and the evidence bundle has them too. Check them with the [checker](verifying-a-record.md):

```sh
node atomside-verify-record.mjs record.json --customer customer.json --approver approver.json
```

On the published test vector `record-5` it prints:

```text
PASS  format     A record for letter ltr_vector0000000005, on record 2026-11-18T16:50:12.456Z.
PASS  hash       The contents match their SHA-256, 25360bf0af1b058c89be49049918dc6342348b0791f399927a1ff36f1039937e.
PASS  key        Signed with Atomside's live key EM9N6_DSYDl0oIMZkkIvuluCIx3GOhsCQB6FlkWBNnY.
PASS  signature  The signature is good: Atomside signed exactly this record.
PASS  customer   The letter was sent for Harbour View Lettings Ltd (ref acct_8821).
PASS  approver   It was approved through a one-time link by J. Sample (ref user_4471).

This record checks out: Atomside signed it and it has not been changed.
```

Openings for another record fail (`FAIL  customer   These customer details are for record rec_…, not rec_…`). The record's public page shows the customer's name only if you chose "Show the customer's name on shared record pages" in Brand and approvals.

## 8. Usage by customer

```sh
curl "https://api.atomside.com/v1/customers/usage?month=2026-11" -H "Authorization: Bearer $ATOMSIDE_MANAGE_KEY"
```

```json
{
  "month": "2026-11",
  "closed": false,
  "totals": {
    "customers": 1,
    "letters": 1,
    "second_class": 1,
    "first_class": 0,
    "extra_sheets": 0,
    "credits": { "credits": 15, "gbp": "1.50" },
    "returned_credits": { "credits": 0, "gbp": "0.00" }
  },
  "customers": [
    {
      "ref": "cust_4471",
      "name": "Acme Lettings",
      "letters": 1,
      "second_class": 1,
      "credits": { "credits": 15, "gbp": "1.50" },
      "returned_credits": { "credits": 0, "gbp": "0.00" }
    }
  ],
  "next_cursor": null
}
```

A letter counts in the UK month it was posted; credits given back count in the month they came back. Shortly after a month ends it is closed and never changes again: webhook `usage.month_closed`. Bill your customers from that.

## 9. Limits, pause and close

Limits count every agent of the workspace. A field left out keeps its value; `null` takes the limit off. `over_limit` is `ask` (a person decides) or `refuse`.

```sh
curl -X PUT https://api.atomside.com/v1/customers/cust_4471/limits \
  -H "Authorization: Bearer $ATOMSIDE_MANAGE_KEY" \
  -H "Idempotency-Key: limits-cust_4471" \
  -H "Content-Type: application/json" \
  -d '{ "per_day_letters": 20, "over_limit": "refuse" }'
```

The answer is the customer, with `"applies": ["20 letters a day", "1,000 letters a month"]`. A letter over a limit is refused `customer_over_limit`, with `retry_after`.

Pause a customer and its letters are refused `customer_paused` from every agent, at quote and at send, until it is resumed:

```sh
curl -X POST https://api.atomside.com/v1/customers/cust_4471/pause \
  -H "Authorization: Bearer $ATOMSIDE_MANAGE_KEY" \
  -H "Idempotency-Key: pause-cust_4471" \
  -H "Content-Type: application/json" \
  -d '{ "reason": "They asked us to stop while they move office." }'
```

The answer has `"state": "paused"` and `paused_at`. A quote for it then answers (HTTP 403, cut down):

```json
{
  "answer": "no",
  "code": "customer_paused",
  "say": "Letters for cust_4471 are paused in this workspace.",
  "retry": "after_person",
  "person": {
    "ask": "Resume this customer",
    "who": "an owner or a developer",
    "if_nothing": "Nothing is sent."
  }
}
```

`POST /v1/customers/cust_4471/resume` lifts it. Limits, pause and resume send no webhooks.

Atomside can also stop one customer's letters (`customer_suspended`, webhooks `customer.suspended` and `customer.suspension_lifted`). Only we can lift it.

When a customer leaves you, ask to close it:

```sh
curl -X POST https://api.atomside.com/v1/customers/cust_4471/close \
  -H "Authorization: Bearer $ATOMSIDE_MANAGE_KEY" \
  -H "Idempotency-Key: close-cust_4471" \
  -H "Content-Type: application/json" \
  -d '{}'
```

Nothing changes yet: the answer is the customer with `close_requested_at` set and `state` still `sending`. We email your owners a link, and an owner closes it in the console. Closing cancels its letters that have not gone and gives back their credits (webhook `customer.closed`), refuses new ones with `customer_closed`, then deletes its letters, addresses and the record openings (webhook `customer.data_deleted`). Its records of posting are kept and still check; they just no longer name anyone.

## 10. Test customers

In test mode these refs always do the same thing, like the [test postcodes](test-mode.md). Each is made the first time you use it.

| Ref                    | What a letter for it does                                    |
| ---------------------- | ------------------------------------------------------------ |
| `cust_test_unverified` | Kept: `customer_sender_unverified` (HTTP 202), as in step 4. |
| `cust_test_over`       | Refused `customer_over_limit`, for the month.                |
| `cust_test_paused`     | Refused `customer_paused`.                                   |
| `cust_test_suspended`  | Refused `customer_suspended`.                                |

For example, a send for `cust_test_over` answers (HTTP 403, cut down):

```json
{
  "answer": "no",
  "code": "customer_over_limit",
  "say": "This letter would take cust_test_over to 2 of its 1 letters this month.",
  "retry": "at_time",
  "retry_after": "2026-12-01T00:00:00.000Z",
  "details": {
    "customer": "cust_test_over",
    "would_reach": 2,
    "limit": 1,
    "unit": "letters",
    "period": "month"
  }
}
```

They cannot be changed: pausing one, or changing its limits, sender or state, is refused `test_customer_fixed` (HTTP 409), "cust_test_over is a test customer. It always does the same thing, so it cannot be changed." In live mode any ref starting `cust_test_` is refused `test_customer_in_live`.

When your account starts sending for customers, its test mode also gets `cust_test_1`, "Example Lettings", with its code posted and waiting for `000000`, so you can try steps 3 to 5 at once.

## 11. Going live as a platform

An account that sends for customers goes live through the console's Go live page, like any other ([Going live](going-live.md)), with these differences:

1. **About your product**: product name, website, registered company, who your customers are and what they post, how many customers and letters you expect in the first three months, and who approves a letter.
2. **Terms, acceptable use and data processing**: the terms for platforms as well, with the data processing terms and the acceptable use you pass on to your customers.
3. **How you pay**: credit packs by card, or ask about the platform plan, paid by invoice.
4. **We read it**: a person at Atomside reads your answers. We may ask a question (answer it on the same page), decline, or approve with a starting number of customers and a starting daily limit for each. Your live keys can be made only once we approve.

Once live:

- Add your first live customer by API or under Customers. We post its code letter.
- A person at Atomside reads each new customer's first five live letters before they print.
- Your starting customer limit lifts by itself once enough customers have passed their first five. Until then, a customer past it is refused `customer_limit_reached`.
- Live keys: one that sends, one that manages customers (step 1).

## See also

- [Writing on behalf of your customers](on-behalf-of.md): `on_behalf_of` and the agent's customer rules.
- [Refusals](refusals.md): every customer code, and what to do.
- [Webhook events](webhooks.md): the `customer.…`, `usage.month_closed` and `capacity.…` events.
- The [operations reference](reference/README.md), from `get_customer_usage` on.
