> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postsyncer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign up from an AI agent

> Let an AI agent in a terminal sign a person up, or into their account, with a code emailed to them, and get an API key.

An AI agent that can make web requests from a terminal, such as Claude Code, Codex, Cursor, OpenClaw or Gemini CLI, can set a person up on PostSyncer without a browser. The agent asks for their email, the person reads back a 6-digit code from their inbox, and the agent gets an API key with every permission.

ChatGPT and Claude's chat app connect through the PostSyncer connector instead, which signs people up in the browser. See [Client setup](https://docs.postsyncer.com/mcp/integrating-clients.md).

## The flow

1. The agent checks whether PostSyncer is already connected, through the Claude plugin or a connector: PostSyncer's tools, such as `list-workspaces`, are in its tool list. If they are, the person is already set up, so it uses those tools and stops, without signing in again or adding the server a second time. If a server named `postsyncer` (or one at `https://postsyncer.com/mcp`) is waiting for a sign-in (in Claude Code, `/mcp` shows it needs authentication), it asks the person to finish that sign-in and stops, instead of signing up again and adding a second server. A `postsyncer` server whose tools fail for another reason, such as a saved key that was deleted, doesn't stop it: the sign-up goes on, and the new key replaces that server.
2. The agent says: "By signing up you agree to PostSyncer's [Terms](https://postsyncer.com/terms-of-service) and [Privacy Policy](https://postsyncer.com/privacy-policy)." Then it asks for the person's email, and nothing else.
3. It asks for a code, with the email, its own name and the computer's time zone.
4. The person reads the code from their inbox. The agent sends it back and gets the key.
5. It saves the key in its own secret store or MCP settings (the shell's profile only when it has neither), then connects the person's social accounts.

Neither request needs a key.

## Send a code

```bash theme={null}
curl -X POST "https://postsyncer.com/api/v1/agent-signup/code" \
  -H "Content-Type: application/json" \
  -d '{ "email": "sam@haldencoffee.com", "agent": "Claude Code", "timezone": "Europe/Berlin" }'
```

```json 202 theme={null}
{
  "message": "We sent a code to sam@haldencoffee.com. It works for 10 minutes.",
  "expires_in": 600
}
```

* The answer is the same whether or not the address has an account, and no account is made yet.
* `agent` is the agent's own name. When PostSyncer knows it (Claude Code, Codex, Cursor, OpenClaw, Gemini CLI, Claude, ChatGPT, VS Code, Windsurf, Hermes, Grok Bot, Grok), the email says "Enter it in Claude Code" and the key is named after it. Any other name is "your AI agent" in the email and "AI agent" on the key.
* Read `timezone` from the system; don't ask. A new account's workspace gets it. A name that isn't an IANA time zone (such as Windows' `Eastern Standard Time`) is left out, not refused.
* A code works for 10 minutes and once. Asking again replaces it.

The email's subject and first line are `Your PostSyncer code is 482913`.

## Verify the code

```bash theme={null}
curl -X POST "https://postsyncer.com/api/v1/agent-signup/verify" \
  -H "Content-Type: application/json" \
  -d '{ "email": "sam@haldencoffee.com", "code": "482913", "agent": "Claude Code" }'
```

```json 200 theme={null}
{
  "api_key": "418|kP3vX9qL2mN8rT5wY7zA1bC4dE6fG0hJ2kL4mN6p",
  "key_name": "Claude Code",
  "new_account": true,
  "user": { "id": 9312, "email": "sam@haldencoffee.com", "name": "sam" },
  "workspace": { "id": 4815, "name": "sam" },
  "first_week_ends_at": "2030-03-20T09:00:00+00:00",
  "mcp_url": "https://postsyncer.com/mcp",
  "setup_url": "https://postsyncer.com/agents/setup.md"
}
```

* A new address gets a new account, with its own workspace and the email marked verified (`new_account: true`).
* An address with an account gets a new key on it, and nothing else on the account changes (`new_account: false`). PostSyncer emails the account's owner that a key was added for the agent, with the key's name and where to delete it.
* `workspace` is where the agent connects accounts and saves posts.
* While a new account is in its first week, `first_week_ends_at` says when the week ends, and the agent says: "For your first 7 days you get 10 accounts, unlimited posts and Analytics. After that you keep Free: 2 accounts and 20 posts a month."

The key has every permission and no end date. It shows in Settings → API under its name, where the person can delete it.

## Save the key

Save `api_key` in the agent's own secret store or its user-level MCP settings first, never in a project file or anything that could be committed, and never repeat the full key in a reply to the person. Only an agent with neither keeps the key in an environment variable such as `POSTSYNCER_API_KEY`, set in the shell's profile (`~/.zshrc` or `~/.bashrc`).

* **Claude Code:**

  ```bash theme={null}
  claude mcp add --transport http --scope user postsyncer https://postsyncer.com/mcp --header "Authorization: Bearer YOUR_API_KEY"
  ```

* **Cursor:** add the server to `~/.cursor/mcp.json`, not the project's `.cursor/mcp.json`:

  ```json theme={null}
  {
    "mcpServers": {
      "postsyncer": {
        "url": "https://postsyncer.com/mcp",
        "headers": { "Authorization": "Bearer YOUR_API_KEY" }
      }
    }
  }
  ```

* **Codex:** in `~/.codex/config.toml`, name an environment variable for the key. Codex has no secret store of its own, so set that variable in the shell's profile (`~/.zshrc` or `~/.bashrc`):

  ```toml theme={null}
  [mcp_servers.postsyncer]
  url = "https://postsyncer.com/mcp"
  bearer_token_env_var = "POSTSYNCER_API_KEY"
  ```

* **Any other agent:** add `https://postsyncer.com/mcp` as a remote server with the header `Authorization: Bearer YOUR_API_KEY` in its user-level settings (see [Connect with a Bearer token](https://docs.postsyncer.com/mcp/integrating-clients.md#connect-with-a-bearer-token)). If its settings read the key from an environment variable instead, set `POSTSYNCER_API_KEY` from its own secret store, or else in the shell's profile.

Most agents load a new MCP server only after a restart. For the rest of the chat, call the REST API with the key as `Authorization: Bearer …`. Later chats use the MCP tools.

## Next: connect accounts and read how posts did

1. Ask which networks the person posts on. Make a [connect link](https://docs.postsyncer.com/api-reference/accounts/connect-link.md) for each, give the links, and check [List accounts](https://docs.postsyncer.com/api-reference/accounts/list.md) until the accounts show up.
2. Once an account is connected, PostSyncer reads its past posts, then learns the brand from them. Read [Get the brand](https://docs.postsyncer.com/api-reference/brand/get.md) until it's done: `importing_posts` is `true` while the posts are still being read, and `status` is `building` while the brand is being learned.
3. When both are done, `accounts[].numbers` has each account's best posts, times and formats. Empty numbers mean there were no past posts to read: ask the person what they do instead.

Save posts as drafts (`schedule_type: draft`) and schedule them only when the person says yes. See [Publish a post](https://docs.postsyncer.com/guides/publish-a-post.md).

## Limits

| Limit | Count |
| - | - |
| Codes for one inbox (`sam+news@gmail.com` and `s.am@gmail.com` count as `sam@gmail.com`) | 3 an hour and 10 a day. Only codes that were sent count: a request refused for a missing or wrong field doesn't. |
| Codes from one IP address | 10 an hour |
| Wrong tries for one code | 5, then the code stops working |
| Wrong codes entered for one inbox | 15 a day, then no more codes are sent to it until the day is over |
| Code checks from one IP address | 30 an hour |
| New accounts from one IP address | 20 a day |

Over a limit, nothing is sent or made, and the answer is `429` with `error: rate_limited`. Wait `Retry-After` seconds when it's given: the day's limits on new accounts from one IP address and on the codes PostSyncer sends give none, and say to try again tomorrow. These two requests carry no `X-RateLimit-*` headers.

## Errors

Every error has `error`, a code to branch on, and a plain `message` to pass on to the person.

| `error` | Status | When | What to do |
| - | - | - | - |
| `code_wrong` | `422` | The code isn't right. `tries_left` says how many more tries it takes. | Ask the person to read it again. |
| `code_expired` | `422` | The code is over 10 minutes old, was used, or was replaced by a newer one. | Ask for a new code. |
| `too_many_tries` | `422` | The code was entered wrong 5 times. | Ask for a new code. |
| `teammate_only` | `403` | The address is only a teammate in someone else's workspace. Only owners get keys. | Tell the person to ask the workspace owner for access. |
| `account_inactive` | `403` | The account is inactive. | Tell the person to write to [support@postsyncer.com](mailto:support@postsyncer.com). |
| `rate_limited` | `429` | A limit above is reached. | Wait `Retry-After` seconds when it's given, then try again. |

## Related

* [Send a sign-up code](https://docs.postsyncer.com/api-reference/agent-signup/code.md) and [Verify a sign-up code](https://docs.postsyncer.com/api-reference/agent-signup/verify.md): the two requests.
* [Authentication](https://docs.postsyncer.com/essentials/authentication.md): keys and permissions.
* [Client setup](https://docs.postsyncer.com/mcp/integrating-clients.md): adding the MCP server to each agent.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.