Lockally Drafts API

Agent draft review and approval (HITL)

GitHub OpenAPI

Operations 7

POST /v1/inboxes/{mailbox}/drafts Propose a new conversation as a draft #
POST /v1/threads/{threadID}/drafts Propose a reply as a draft #
GET /v1/drafts List drafts #
GET /v1/drafts/{draftID} Get a draft #
POST /v1/drafts/{draftID}/approve Approve a pending draft (human) #
POST /v1/drafts/{draftID}/reject Reject a pending draft (human) #
POST /v1/drafts/{draftID}/cancel Withdraw a pending draft #

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-drafts-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-drafts-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: lockally control plane Drafts 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: Drafts
  description: Agent draft review and approval (HITL)
paths:
  /v1/inboxes/{mailbox}/drafts:
    post:
      operationId: createConversationDraft
      tags:
      - Drafts
      summary: Propose a new conversation as a draft
      description: New-conversation drafts ALWAYS require human approval (policy flag new_thread). Idempotency-Key required.
      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
      responses:
        '202':
          description: Draft outcome (pending_approval)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DraftResult'
  /v1/threads/{threadID}/drafts:
    post:
      operationId: createReplyDraft
      tags:
      - Drafts
      summary: Propose a reply as a draft
      description: 'The safe default over /reply: the deterministic policy engine auto-sends clean in-thread replies and holds anything risky (PII, new recipients, injection-flagged threads, always-approve mailboxes) for human approval. Fires draft.pending_approval when held. 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: Outcome (sent | pending_approval) with policy_flags
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DraftResult'
  /v1/drafts:
    get:
      operationId: listDrafts
      tags:
      - Drafts
      summary: List drafts
      description: Filter with ?status=pending_approval|sent|rejected|cancelled. Keys see drafts of granted mailboxes; admin sessions see all.
      x-required-scope: inboxes:read
      parameters:
      - name: status
        in: query
        schema:
          type: string
      - name: limit
        in: query
        schema:
          type: integer
          default: 50
          maximum: 200
      responses:
        '200':
          description: Drafts
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DraftList'
  /v1/drafts/{draftID}:
    get:
      operationId: getDraft
      tags:
      - Drafts
      summary: Get a draft
      x-required-scope: inboxes:read
      parameters:
      - name: draftID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Draft
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Draft'
  /v1/drafts/{draftID}/approve:
    post:
      operationId: approveDraft
      tags:
      - Drafts
      summary: Approve a pending draft (human)
      description: Sends the draft exactly as reviewed, through the agent stream (loop detector included). Fires draft.approved.
      x-required-scope: tenant:admin
      parameters:
      - name: draftID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Sent
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DraftResult'
  /v1/drafts/{draftID}/reject:
    post:
      operationId: rejectDraft
      tags:
      - Drafts
      summary: Reject a pending draft (human)
      description: 'Body: {"reason": "..."} (optional). Fires draft.rejected.'
      x-required-scope: tenant:admin
      parameters:
      - name: draftID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Rejected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Draft'
  /v1/drafts/{draftID}/cancel:
    post:
      operationId: cancelDraft
      tags:
      - Drafts
      summary: Withdraw a pending draft
      description: Only the API key that created the draft may cancel it.
      x-required-scope: inboxes:write
      parameters:
      - name: draftID
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Cancelled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Draft'
components:
  schemas:
    PolicyFlags:
      type: object
      description: 'Why a draft was held. A key is absent when that check passed. The set is closed: a flag added to the policy engine must be added here too, or typed clients will drop it.

        '
      properties:
        always_approve:
          type: boolean
        injection_risk:
          type: boolean
        new_recipient:
          type: array
          items:
            type: string
        new_thread:
          type: boolean
        pii:
          type: array
          items:
            type: string
        recipient_count:
          type: integer
    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.
    Draft:
      type: object
      required:
      - id
      - mailbox_id
      - to
      - status
      - policy_flags
      - created_at
      - updated_at
      properties:
        id:
          type: string
          format: uuid
        mailbox_id:
          type: string
          format: uuid
        mailbox:
          type: string
          format: email
        thread_id:
          type: string
          format: uuid
        to:
          type: array
          items:
            type: string
            format: email
        cc:
          type: array
          items:
            type: string
            format: email
        subject:
          type: string
        body_text:
          type: string
        status:
          type: string
          enum:
          - pending_approval
          - sent
          - rejected
          - cancelled
        policy_flags:
          $ref: '#/components/schemas/PolicyFlags'
        reviewed_at:
          type: string
          format: date-time
        sent_message_id:
          type: string
          format: uuid
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    DraftResult:
      type: object
      required:
      - draft_id
      - status
      - policy_flags
      properties:
        draft_id:
          type: string
          format: uuid
        status:
          type: string
          enum:
          - pending_approval
          - sent
        policy_flags:
          $ref: '#/components/schemas/PolicyFlags'
        thread_id:
          type: string
          format: uuid
        sent:
          $ref: '#/components/schemas/AgentSendResult'
    DraftList:
      type: object
      required:
      - drafts
      properties:
        drafts:
          type: array
          items:
            $ref: '#/components/schemas/Draft'
  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