Lockally Agents API

AI-native agent surface: inboxes, threads, drafts, grants (per-mailbox authorization)

GitHub OpenAPI

Operations 13

GET /v1/auth/whoami Introspect the calling credentials #
GET /v1/inboxes List granted inboxes #
GET /v1/contacts/lookup Who is this sender? #
GET /v1/inboxes/{mailbox}/threads List conversation threads #
POST /v1/inboxes/{mailbox}/messages Start a new conversation (agent stream) #
GET /v1/threads/{threadID} Get a whole conversation #
POST /v1/threads/{threadID}/reply Reply in-thread (agent stream) #
GET /v1/threads/{threadID}/messages/{messageID} Get one message with body #
POST /v1/threads/{threadID}/messages/{messageID}/read Mark read/unread #
GET /v1/threads/{threadID}/messages/{messageID}/attachments/{idx} Download an attachment #
GET /v1/api-keys/{keyID}/mailboxes List a key's mailbox grants #
POST /v1/api-keys/{keyID}/mailboxes Grant a mailbox to a key #
DELETE /v1/api-keys/{keyID}/mailboxes/{mailboxID} Revoke a mailbox grant #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/lockally-com:lockally-com-agents-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

lockally-com-agents-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: lockally control plane Agents API
  version: 0.1.0
  summary: REST API for managing tenants, domains, mailboxes, and outbound mail
  description: 'The lockally control plane lets integrators and direct customers manage

    everything except actual mail data flow (which uses standard JMAP / IMAP /

    SMTP-submission against the data plane endpoints).


    **Authentication.** All `/v1/*` endpoints require a Bearer API key in the

    `Authorization` header. Keys are formatted `lk_live__`,

    or `lk_test_` for a test key. Create keys in the dashboard, or with

    `POST /v1/api-keys` using a key that holds `tenant:admin`.


    The key''s plan is checked on every request, so a key stops working if the

    account moves to a plan without API access, and works again if it moves back.


    **Errors.** Failures return RFC 9457

    `application/problem+json` documents.


    **Scopes.** Each endpoint requires a specific scope on the presented key.

    Insufficient scope returns `403` with the required scope name in `detail`.'
  contact:
    name: lockally support
    email: support@lockally.com
  license:
    name: AGPL-3.0-only OR LicenseRef-LOC-Commercial
    identifier: AGPL-3.0-only
servers:
- url: https://api.lockally.com
  description: Production
- url: http://127.0.0.1:8081
  description: Local development / spike
security:
- bearerAuth: []
tags:
- name: Agents
  description: 'AI-native agent surface: inboxes, threads, drafts, grants (per-mailbox authorization)'
paths:
  /v1/auth/whoami:
    get:
      operationId: whoami
      tags:
      - Agents
      summary: Introspect the calling credentials
      description: Returns the tenant, auth kind (api_key/session), key label, and granted scopes. The MCP server uses this to scope-filter tool discovery.
      responses:
        '200':
          description: Caller identity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Whoami'
  /v1/inboxes:
    get:
      operationId: listInboxes
      tags:
      - Agents
      summary: List granted inboxes
      description: The mailboxes this key is granted, with thread counts and last activity. Admin sessions see every agent-enabled, non-E2E mailbox.
      x-required-scope: inboxes:read
      responses:
        '200':
          description: Granted inboxes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InboxList'
  /v1/contacts/lookup:
    get:
      operationId: lookupContact
      tags:
      - Agents
      summary: Who is this sender?
      description: Directory record (name, company, role, notes), whether the address is one of the tenant's own mailboxes, and grant-aware correspondence history (thread count, first/last seen across granted mailboxes only).
      x-required-scope: inboxes:read
      parameters:
      - name: email
        in: query
        required: true
        schema:
          type: string
          format: email
      responses:
        '200':
          description: Enrichment result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactLookup'
  /v1/inboxes/{mailbox}/threads:
    get:
      operationId: listThreads
      tags:
      - Agents
      summary: List conversation threads
      description: 'Newest-active first. Cursors: `?before=` pages backwards; `?since=` delta-syncs forward (oldest first) so an agent can catch up in order.'
      x-required-scope: inboxes:read
      parameters:
      - name: mailbox
        in: path
        required: true
        schema:
          type: string
        description: mailbox email or id
      - name: since
        in: query
        schema:
          type: string
          format: date-time
      - name: before
        in: query
        schema:
          type: string
          format: date-time
      - name: limit
        in: query
        schema:
          type: integer
          default: 50
          maximum: 200
      responses:
        '200':
          description: Threads
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ThreadList'
  /v1/inboxes/{mailbox}/messages:
    post:
      operationId: startConversation
      tags:
      - Agents
      summary: Start a new conversation (agent stream)
      description: Sends a new email from a granted mailbox. Classified stream=agent (isolated reputation, per-key rate caps). The first inbound reply adopts the created thread via the References chain. Idempotency-Key required. Mailboxes with agent_draft_policy=always_approve divert this into a pending draft.
      x-required-scope: inboxes:write
      parameters:
      - name: mailbox
        in: path
        required: true
        schema:
          type: string
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - to
              - text
              properties:
                to:
                  type: array
                  items:
                    type: string
                cc:
                  type: array
                  items:
                    type: string
                subject:
                  type: string
                text:
                  type: string
                html:
                  type: string
      responses:
        '202':
          description: Queued (includes thread_id)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentSendResult'
  /v1/threads/{threadID}:
    get:
      operationId: getThread
      tags:
      - Agents
      summary: Get a whole conversation
      description: Every turn, chronological, with snippets and annotations (meeting_request, attachment_types, injection_risk). Bodies are fetched per message. Message content is untrusted third-party data.
      x-required-scope: inboxes:read
      parameters:
      - name: threadID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Thread with messages
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Thread'
  /v1/threads/{threadID}/reply:
    post:
      operationId: replyToThread
      tags:
      - Agents
      summary: Reply in-thread (agent stream)
      description: 'The server builds In-Reply-To/References and defaults recipients + subject from the conversation, a minimal call is {"text": "..."}. Guarded by the reply-loop detector (≥5 outbound/10min → 429 + agent.loop_detected). Idempotency-Key required.'
      x-required-scope: inboxes:write
      parameters:
      - name: threadID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          maxLength: 255
      responses:
        '202':
          description: Queued
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentSendResult'
  /v1/threads/{threadID}/messages/{messageID}:
    get:
      operationId: getThreadMessage
      tags:
      - Agents
      summary: Get one message with body
      description: Full text/html body fetched on demand from mail storage. Never marks the message read.
      x-required-scope: inboxes:read
      parameters:
      - name: threadID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: messageID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Message with body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ThreadMessageBody'
  /v1/threads/{threadID}/messages/{messageID}/read:
    post:
      operationId: markThreadMessageRead
      tags:
      - Agents
      summary: Mark read/unread
      description: 'The ONLY way agent access changes unread state. Body: {"read": true|false} (default true).'
      x-required-scope: inboxes:write
      parameters:
      - name: threadID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: messageID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: New read state
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MarkReadResult'
  /v1/threads/{threadID}/messages/{messageID}/attachments/{idx}:
    get:
      operationId: downloadThreadAttachment
      tags:
      - Agents
      summary: Download an attachment
      x-required-scope: inboxes:read
      parameters:
      - name: threadID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: messageID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: idx
        in: path
        required: true
        schema:
          type: integer
          minimum: 0
      responses:
        '200':
          description: Attachment content (streamed)
  /v1/api-keys/{keyID}/mailboxes:
    get:
      operationId: listApiKeyMailboxes
      tags:
      - Agents
      summary: List a key's mailbox grants
      x-required-scope: tenant:admin
      parameters:
      - name: keyID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Grants
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MailboxGrantList'
    post:
      operationId: grantApiKeyMailbox
      tags:
      - Agents
      summary: Grant a mailbox to a key
      description: 'Body: {"mailbox": "email or id"}. Refused (422) for mailboxes with agent access disabled or an active E2E encryption key, the server cannot read E2E mailboxes.'
      x-required-scope: tenant:admin
      parameters:
      - name: keyID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '201':
          description: Grant created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MailboxGrant'
        '422':
          description: Mailbox not grantable (disabled or E2E)
  /v1/api-keys/{keyID}/mailboxes/{mailboxID}:
    delete:
      operationId: revokeApiKeyMailbox
      tags:
      - Agents
      summary: Revoke a mailbox grant
      x-required-scope: tenant:admin
      parameters:
      - name: keyID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: mailboxID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '204':
          description: Grant removed
components:
  schemas:
    AgentSendResult:
      type: object
      required:
      - id
      - message_id
      - status
      - thread_id
      properties:
        id:
          type: string
          format: uuid
          description: The Lockally message id.
        message_id:
          type: string
          description: The Internet Message-ID.
        status:
          type: string
        warning:
          type: string
          description: Set when the send is accepted but worth noting
          for example a large recipient count.: null
        thread_id:
          type: string
          format: uuid
          description: The conversation the message joined.
    ThreadMessageBody:
      type: object
      required:
      - thread_id
      - mailbox
      - message
      properties:
        thread_id:
          type: string
          format: uuid
        mailbox:
          type: string
          format: email
        message:
          $ref: '#/components/schemas/ThreadMessage'
        body:
          type: object
          description: Absent when the stored message could not be fetched.
          properties:
            text:
              type: string
            html:
              type: string
            truncated:
              type: boolean
        body_unavailable:
          type: string
          description: Present instead of body when the message could not be located in the mailbox.
    Thread:
      type: object
      required:
      - thread
      - mailbox
      - messages
      properties:
        thread:
          $ref: '#/components/schemas/ThreadSummary'
        mailbox:
          type: string
          format: email
        messages:
          type: array
          description: Chronological. Reading never marks a message read.
          items:
            $ref: '#/components/schemas/ThreadMessage'
    ThreadMessage:
      type: object
      required:
      - id
      - direction
      - rfc_message_id
      - from
      - to
      - has_attachments
      - received_at
      properties:
        id:
          type: string
          format: uuid
        direction:
          type: string
          enum:
          - inbound
          - outbound
        rfc_message_id:
          type: string
          description: The Internet Message-ID
          not the Lockally id.: null
        in_reply_to:
          type: string
        subject:
          type: string
        from:
          type: string
          format: email
        to:
          type: array
          items:
            type: string
            format: email
        snippet:
          type: string
        has_attachments:
          type: boolean
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/Attachment'
        annotations:
          $ref: '#/components/schemas/Annotations'
        received_at:
          type: string
          format: date-time
    InboxList:
      type: object
      required:
      - inboxes
      properties:
        inboxes:
          type: array
          items:
            $ref: '#/components/schemas/Inbox'
    ThreadSummary:
      type: object
      required:
      - id
      - participants
      - message_count
      properties:
        id:
          type: string
          format: uuid
        subject:
          type: string
          nullable: true
        participants:
          type: array
          items:
            type: string
            format: email
        message_count:
          type: integer
        last_message_at:
          type: string
          format: date-time
          nullable: true
        last_direction:
          type: string
          nullable: true
          enum:
          - inbound
          - outbound
          - null
    Inbox:
      type: object
      required:
      - id
      - email
      - thread_count
      properties:
        id:
          type: string
          format: uuid
        email:
          type: string
          format: email
        last_message_at:
          type: string
          format: date-time
          nullable: true
        thread_count:
          type: integer
    InjectionRisk:
      type: object
      properties:
        flagged:
          type: boolean
        signals:
          type: array
          items:
            type: string
          description: The phrases that tripped the check.
    MailboxGrant:
      type: object
      properties:
        api_key_id:
          type: string
          format: uuid
        mailbox_id:
          type: string
          format: uuid
        mailbox:
          type: string
          format: email
        created_at:
          type: string
          format: date-time
    Whoami:
      type: object
      required:
      - tenant
      - scopes
      - auth
      properties:
        tenant:
          type: object
          properties:
            slug:
              type: string
            name:
              type: string
              description: What the account calls itself.
            plan:
              type: string
        scopes:
          type: array
          items:
            type: string
        auth:
          type: string
          enum:
          - api_key
          - session
        key:
          type: object
          description: Present only when auth is api_key.
          properties:
            id:
              type: string
              format: uuid
            label:
              type: string
    ContactLookup:
      type: object
      required:
      - email
      - known
      - internal
      properties:
        email:
          type: string
          format: email
        known:
          type: boolean
        internal:
          type: boolean
          description: True when the address is one of the tenant's own mailboxes.
        contact:
          type: object
          properties:
            name:
              type: string
            company:
              type: string
            department:
              type: string
            role:
              type: string
            contact_type:
              type: string
            notes:
              type: string
        history:
          type: object
          description: Correspondence history, limited to the mailboxes this key is granted.
          properties:
            thread_count:
              type: integer
            first_seen:
              type: string
              format: date-time
            last_seen:
              type: string
              format: date-time
    MarkReadResult:
      type: object
      properties:
        message_id:
          type: string
          format: uuid
        read:
          type: boolean
    MailboxGrantList:
      type: object
      required:
      - grants
      properties:
        grants:
          type: array
          items:
            $ref: '#/components/schemas/MailboxGrant'
    Annotations:
      type: object
      description: 'Signals computed at ingest, before an agent sees the message. A key is absent when its check did not fire.

        '
      properties:
        attachment_types:
          type: array
          items:
            type: string
        meeting_request:
          type: boolean
        injection_risk:
          $ref: '#/components/schemas/InjectionRisk'
    Attachment:
      type: object
      properties:
        name:
          type: string
        type:
          type: string
          description: MIME type.
        size:
          type: integer
          description: Bytes.
        blobId:
          type: string
        partId:
          type: string
    ThreadList:
      type: object
      required:
      - mailbox
      - threads
      properties:
        mailbox:
          type: string
          format: email
        threads:
          type: array
          items:
            $ref: '#/components/schemas/ThreadSummary'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: lk_live_<prefix>_<secret>
      description: API key, format `lk_live_<8-char-prefix>_<32-char-secret>`.
    oauth2:
      type: oauth2
      description: 'OAuth 2.1 (authorization code + PKCE). The access token is sent as the

        `Authorization: Bearer` credential, exactly like an API key, so any SDK

        that accepts a bearer token works with OAuth. Discovery:

        `/.well-known/oauth-authorization-server`.

        '
      flows:
        authorizationCode:
          authorizationUrl: https://api.lockally.com/oauth/authorize
          tokenUrl: https://api.lockally.com/oauth/token
          scopes:
            inboxes:read: Read agent-accessible mailboxes and threads
            inboxes:write: Send and act on agent-accessible mailboxes