> ## 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.

# Send a sign-up code

> Email a person a 6-digit code, so an AI agent can sign them up or into their account and get a key.

> [!NOTE]
>
> No key needed. This is how an AI agent gets a person's first key. See [Sign up from an AI agent](https://docs.postsyncer.com/guides/agent-signup.md) for the whole flow.

Emails a 6-digit code to the address. The person reads it back to the agent, who sends it to [Verify a sign-up code](https://docs.postsyncer.com/api-reference/agent-signup/verify.md) and gets an API key.

Before asking for the address, the agent tells the person: "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 email, and nothing else.

* The answer is the same whether or not the address has an account. No account is made here: it's made when the code is verified.
* A code works for 10 minutes and once. Asking again replaces it: the earlier code stops working.
* Send the agent's own name in `agent`. 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". Any other name is "your AI agent".
* Send the computer's time zone in `timezone`, read from the system. A new account's workspace gets it.

The email's subject and first line are `Your PostSyncer code is 482913`, so Gmail offers to copy the code.

## 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 |
| Codes from one IP address | 10 an hour |

Over a limit, no email is sent and the answer is `429` with `error: rate_limited`. PostSyncer also sends a set number of codes a day in all; past it, the answer is the same `429`.

## Errors

| Status | `error` | When | Retry? |
| - | - | - | - |
| 404 | | Agent sign-up isn't switched on. | No. |
| 422 | | The email is missing or not an address, `agent` is missing or longer than 60 characters, or `timezone` isn't a time zone. | No: fix the request. |
| 429 | `rate_limited` | A limit above is reached. | Yes, after `Retry-After` seconds when it's given. |

## Related

* [Verify a sign-up code](https://docs.postsyncer.com/api-reference/agent-signup/verify.md): the next step.
* [Sign up from an AI agent](https://docs.postsyncer.com/guides/agent-signup.md): the flow, the key and where to save it.


## OpenAPI

````yaml POST /agent-signup/code
openapi: 3.0.3
info:
  title: PostSyncer API
  description: >-
    Post to 12 social networks from your code: posts, media, comments,
    analytics, webhooks and more.
  version: 1.0.0
servers:
  - url: https://postsyncer.com/api/v1
security:
  - bearerAuth: []
tags:
  - name: Workspaces
    description: The workspaces the key can reach.
  - name: Accounts
    description: Connected social accounts, links to connect more, and disconnecting them.
  - name: Posts
    description: Drafts, scheduled and published posts, approvals and a post's history.
  - name: Post settings
    description: A post's auto-plug, comment moderation and contact collection.
  - name: Media
    description: >-
      The media library: file uploads, URL imports, and reading videos and
      social posts' files.
  - name: Folders
    description: Folders that organise the media library.
  - name: Comments
    description: >-
      Comments on your posts: reading, replying, editing, hiding, deleting and
      syncing them.
  - name: Reviews
    description: Google Business Profile reviews and your replies to them.
  - name: Analytics
    description: Workspace, account and post performance.
  - name: Brand
    description: >-
      A workspace's brand: identity, voice, look, accounts, competitors,
      learnings and rules.
  - name: Labels
    description: Labels used to tag posts.
  - name: Campaigns
    description: Campaigns used to group posts.
  - name: Snippets
    description: Saved snippets and hashtag groups to drop into posts.
  - name: Webhooks
    description: Signed webhook endpoints that get your notification events.
  - name: Billing
    description: >-
      The owner's plan, invoices and the links that pay for, change or cancel
      it.
  - name: Team
    description: A workspace's teammates and invitations, and their roles.
  - name: Notifications
    description: >-
      Your bell and notification settings, and the workspace's Slack, Discord
      and Telegram channels.
  - name: Blog-to-social
    description: Blog feeds that turn a workspace's new articles into posts.
  - name: Products
    description: Products the workspace's posts can promote.
  - name: Contacts
    description: People who commented on the workspace's posts, and the lists they are on.
  - name: Profile
    description: 'The key''s user: their name and sign-in email.'
  - name: API keys
    description: 'Your API keys: listing and deleting them.'
  - name: Agent sign-up
    description: >-
      An AI agent signs a person up with a code emailed to them, and gets their
      first key. No key needed.
paths:
  /agent-signup/code:
    post:
      tags:
        - Agent sign-up
      summary: Send a sign-up code
      description: >-
        No key needed. For an AI agent signing a person up from a terminal:
        emails a 6-digit code to the address, which the person reads back to the
        agent, who sends it to [Verify a sign-up
        code](/api-reference/agent-signup/verify) for a key. The answer is the
        same whether or not the address has an account, and no account is made
        here. A code works for 10 minutes and once; asking again replaces it.
        Before asking, tell the person: "By signing up you agree to PostSyncer's
        Terms and Privacy Policy." Limits: 3 codes an hour and 10 a day per
        inbox (a +tag, and dots in a Gmail address, count as the same inbox),
        and 10 an hour per IP address.
      operationId: sendAgentSignupCode
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - email
                - agent
              properties:
                email:
                  type: string
                  format: email
                  maxLength: 254
                  description: >-
                    The person's email address. Ask them for it; ask for nothing
                    else.
                agent:
                  type: string
                  maxLength: 60
                  description: >-
                    Your own name, such as `Claude Code`, `Codex`, `Cursor`,
                    `OpenClaw` or `Gemini CLI`. The email and the key are named
                    after it when PostSyncer knows the name; any other name is
                    "your AI agent" in the email and "AI agent" on the key.
                timezone:
                  type: string
                  nullable: true
                  description: >-
                    The computer's time zone, as an IANA name such as
                    `Europe/Berlin`. Read it from the system; don't ask. A new
                    account's workspace gets it; otherwise UTC. A name that
                    isn't a time zone is left out, not refused.
                language:
                  type: string
                  nullable: true
                  maxLength: 10
                  description: >-
                    The person's language code, such as `en`. A new account's
                    workspace gets it; otherwise `en`.
            examples:
              default:
                summary: Claude Code asks for a code
                value:
                  email: sam@haldencoffee.com
                  agent: Claude Code
                  timezone: Europe/Berlin
      responses:
        '202':
          description: >-
            The code is on its way. The same answer whether or not the address
            has an account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentSignupCodeSent'
              examples:
                default:
                  summary: Sent
                  value:
                    message: >-
                      We sent a code to sam@haldencoffee.com. It works for 10
                      minutes.
                    expires_in: 600
        '404':
          $ref: '#/components/responses/AgentSignupOff404'
        '422':
          $ref: '#/components/responses/ValidationError422'
        '429':
          description: >-
            A limit is reached, and no email was sent: 3 codes an hour or 10 a
            day for this address, 15 wrong codes entered for it today, 10 an
            hour from this IP address, or PostSyncer's codes for the day. Wait
            `Retry-After` seconds when it's given.
          headers:
            Retry-After:
              description: Seconds until requests are allowed again.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentSignupError'
              examples:
                hour:
                  summary: 3 codes this hour for the address
                  value:
                    error: rate_limited
                    message: Too many tries. Try again in 60 minutes.
                day:
                  summary: 10 codes today for the address
                  value:
                    error: rate_limited
                    message: Too many tries. Try again in 24 hours.
                daily_cap:
                  summary: PostSyncer's codes for the day are sent
                  value:
                    error: rate_limited
                    message: We can't send any more codes today. Try again tomorrow.
      security: []
components:
  schemas:
    AgentSignupCodeSent:
      type: object
      description: A sign-up code was sent.
      required:
        - message
        - expires_in
      properties:
        message:
          type: string
          description: Plain words to pass on to the person.
        expires_in:
          type: integer
          description: 'Seconds the code works for: 600.'
    AgentSignupError:
      type: object
      description: >-
        Agent sign-up said no. Branch on `error`; pass `message` on to the
        person.
      required:
        - error
        - message
      properties:
        error:
          type: string
          enum:
            - code_wrong
            - code_expired
            - too_many_tries
            - teammate_only
            - account_inactive
            - rate_limited
          description: What happened.
        message:
          type: string
          description: Plain words to pass on to the person.
        tries_left:
          type: integer
          minimum: 0
          description: '`code_wrong` only: how many more tries the code takes.'
    Error:
      type: object
      description: >-
        An error answer. Every one has `message`, in plain words; some add an
        `error` code and fields of their own.
      required:
        - message
      properties:
        message:
          type: string
          description: What went wrong and what to do about it.
        error:
          type: string
          description: >-
            A code a few errors add, such as `rate_limited`. See [Handle
            errors](/essentials/error-handling#answers-with-an-error-code).
    ValidationError:
      type: object
      description: '422: the request didn''t pass validation, and nothing changed.'
      required:
        - message
        - errors
      properties:
        message:
          type: string
          description: >-
            The first error and, when there are more, how many: `(and 1 more
            error)`, `(and 2 more errors)`.
        errors:
          type: object
          description: >-
            The messages, by field. A field inside a list is named with dots:
            `accounts.0.id`.
          additionalProperties:
            type: array
            items:
              type: string
  responses:
    AgentSignupOff404:
      description: Agent sign-up isn't switched on.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            not_found:
              summary: Not switched on
              value:
                message: Not found.
    ValidationError422:
      description: >-
        The request didn't pass validation, and nothing changed. `errors` has
        the messages by field.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
          examples:
            validation_failed:
              summary: A required field is missing
              value:
                message: The workspace id field is required.
                errors:
                  workspace_id:
                    - The workspace id field is required.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

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