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

# Create an API key

> Creates an access token. The `key` is in this response **only**; store it safely.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api-keys
openapi: 3.1.0
info:
  title: PigeonPost API
  version: 1.0.0
  description: >
    Connect your users' mailboxes (Gmail with an app password, and any IMAP/SMTP
    provider), read, send and manage their email, and

    receive webhooks when something changes. The API follows Unipile's v2
    conventions (ids, lists,

    events); its own version is v1.


    **Authentication:** every request needs your access token in the `X-API-KEY`
    header. Create

    tokens in your dashboard under **API keys**, or with `POST
    /api/v1/api-keys`.


    **Base URL:** `https://{your DSN}/api/v1`. Your DSN is shown in your
    dashboard.


    **Ids** carry their type: `acc_…` (account), `email_…`, `att_…`
    (attachment), `fld_…`

    (folder), `drf_…` (draft), `we_…` (webhook endpoint), `evt_…` (event),
    `pk_…` (API key).


    **Lists** are `{ "object": "<Plural>", "data": [...], "has_more": true|false
    }`. Accounts,

    webhook endpoints, conversations and API keys page with `offset` and
    `limit`. Emails, drafts

    and contacts page with a `cursor`: pass the `cursor` of a response back to
    get the next page.


    **Errors** always have the same JSON shape: `status`, `type`, `title`,
    `detail`.
servers:
  - url: https://{dsn}/api/v1
    description: Your workspace's DSN, from your dashboard
    variables:
      dsn:
        default: mail-api.example.com
        description: Your DSN, for example mail-api.example.com
security:
  - apiKey: []
tags:
  - name: Auth
    description: Connect a mailbox from your app (IMAP/SMTP).
  - name: Accounts
    description: The mailboxes connected to your workspace.
  - name: Emails
    description: Read, search, send, change and delete emails.
  - name: Attachments
    description: Download the files attached to an email.
  - name: Drafts
    description: Drafts saved in the user's mailbox.
  - name: Folders
    description: Folders (Gmail labels appear as folders over IMAP).
  - name: Contacts
    description: The people an account has emailed with.
  - name: Webhooks
    description: Get notified when something happens in a mailbox.
  - name: API keys
    description: Access tokens for this API.
paths:
  /api-keys:
    post:
      tags:
        - API keys
      summary: Create an API key
      description: >-
        Creates an access token. The `key` is in this response **only**; store
        it safely.
      operationId: createApiKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 100
                  description: Your name for the key.
                  example: Production
      responses:
        '200':
          description: The key.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiKey'
                  - type: object
                    properties:
                      key:
                        type: string
                        description: The access token. Shown once.
              example:
                object: ApiKey
                id: pk_0f1e2d3c4b5a69788796a5b4c3d2e1f0
                name: Production
                prefix: ee_Zq3Rk
                role: service
                issued_at: '2026-10-07T08:00:00Z'
                last_used_at: null
                key: ee_Zq3Rk8Tn2Vb6Xy1Lm4Pw7Hs9Jd5Fg0aB
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    ApiKey:
      type: object
      properties:
        object:
          type: string
          const: ApiKey
        id:
          type: string
          description: '`pk_…`'
        name:
          type: string
        prefix:
          type: string
          description: The first characters, to recognise the key.
        role:
          type: string
          const: service
        issued_at:
          type: string
          format: date-time
        last_used_at:
          type:
            - string
            - 'null'
          format: date-time
    Error:
      type: object
      properties:
        status:
          type: integer
        type:
          type: string
          enum:
            - errors/invalid_parameters
            - errors/unauthorized
            - errors/invalid_credentials
            - errors/not_found
            - errors/already_exists
            - errors/provider_rejected
            - errors/provider_error
            - errors/unexpected_error
        title:
          type: string
        detail:
          type: string
  responses:
    BadRequest:
      description: A parameter is missing or wrong. `detail` says which.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            status: 400
            type: errors/invalid_parameters
            title: Invalid parameters
            detail: limit must be between 1 and 250
    Unauthorized:
      description: The `X-API-KEY` header is missing, wrong or revoked.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            status: 401
            type: errors/unauthorized
            title: Unauthorized
            detail: missing or invalid API key
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-KEY
      description: Your access token, from your dashboard under **API keys**.

````

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