openapi: 3.1.0
info:
  title: HumanBlend developer API
  version: "1.0"
  summary: Run HumanBlend from your own code, your automations and your AI assistant.
  description: |
    The public contract of `https://api.humanblended.com/v1` (docs/architecture/30 and 31.11). The app's own `/api` is
    described in `openapi.yaml` and is not a public contract.
  contact:
    name: HumanBlend developer support
    url: https://humanblended.com/contact
servers:
  - url: https://api.humanblended.com/v1
security:
  - bearer: []
tags:
  - { name: Account, description: "Your plan, credits and limits." }
  - { name: Plans and billing, description: "Choose a plan and manage billing. You always pay in the browser, on Stripe's page." }
  - { name: Runs, description: "Humanize a text, then follow the run." }
  - { name: AI checks, description: "Read a text with both AI checks." }
  - { name: Bulk runs, description: "Up to 100 texts in one call." }
  - { name: Webhooks, description: "Get told when a run, check or batch finishes." }
paths:
  /account:
    get:
      tags: [Account]
      operationId: getAccount
      summary: Get the account
      description: Your plan, the credits you have, SEO articles, the limits that apply, and this key's scopes and use this month. Works on an account with no plan, so an integration can show the next step.
      x-scope: read
      x-allowed-without-plan: true
      responses:
        "200":
          description: The account.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Account" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /estimate:
    post:
      tags: [Account]
      operationId: estimateCost
      summary: Estimate a run
      description: How many words and credits a text would use, whether you have them, and how many you are short. Charges nothing.
      x-scope: read
      x-allowed-without-plan: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [text]
              properties:
                text: { $ref: "#/components/schemas/Text" }
                format: { $ref: "#/components/schemas/Format" }
      responses:
        "200":
          description: The estimate.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Estimate" }
        "400": { $ref: "#/components/responses/ValidationFailed" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /plans:
    get:
      tags: [Plans and billing]
      operationId: listPlans
      summary: List plans
      description: The monthly and annual plans with price, credits and limits, and whether this account can start the card trial. Enterprise is not listed (it is priced by credits, in the app). `data` is empty while billing is closed.
      x-scope: read
      x-allowed-without-plan: true
      responses:
        "200":
          description: The plans.
          content:
            application/json:
              schema:
                type: object
                required: [object, data, trial]
                properties:
                  object: { type: string, const: list }
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/Plan" }
                  trial: { $ref: "#/components/schemas/TrialOffer" }
        "401": { $ref: "#/components/responses/Unauthorized" }
  /checkout:
    post:
      tags: [Plans and billing]
      operationId: startCheckout
      summary: Start a plan
      description: |
        Returns a Stripe Checkout link for this account, with the card trial when the account is eligible. The person pays in the browser; nothing is charged through the API.

        If the account already has a subscription, the answer is `409 plan_active`: use the billing portal instead. Only the account owner can start a plan: a key made by a member answers `403 forbidden`. Enterprise cannot be started here (`400 validation_failed`). `403 account_frozen`. `503 billing_unavailable` when billing is closed. A replay with the same `Idempotency-Key` returns the same link; a different body with the same key is `409 idempotency_conflict`.
      x-scope: billing
      x-allowed-without-plan: true
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [plan, interval]
              properties:
                plan: { type: string, description: "A plan `code` from `GET /plans`." }
                interval: { type: string, enum: [month, year] }
      responses:
        "201":
          description: The checkout link.
          content:
            application/json:
              schema:
                type: object
                required: [object, url, expires_at, trial]
                properties:
                  object: { type: string, const: checkout }
                  url: { type: string, format: uri }
                  expires_at: { type: string, format: date-time }
                  trial: { type: boolean, description: Whether this checkout starts the card trial. }
        "400": { $ref: "#/components/responses/ValidationFailed" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "409":
          description: "`plan_active`: the account already has a subscription."
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Error" }
  /billing/portal:
    post:
      tags: [Plans and billing]
      operationId: openBillingPortal
      summary: Open the billing portal
      description: A Stripe customer portal link, where the person changes card, reads invoices, changes plan or cancels. The link is short-lived (`expires_at` is 5 minutes from now), so open it at once. Needs no `Idempotency-Key`. `409 no_customer` when the account never paid.
      x-scope: billing
      x-allowed-without-plan: true
      responses:
        "201":
          description: The portal link.
          content:
            application/json:
              schema:
                type: object
                required: [object, url, expires_at]
                properties:
                  object: { type: string, const: portal }
                  url: { type: string, format: uri }
                  expires_at: { type: string, format: date-time }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "409":
          description: "`no_customer`: the account never paid."
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Error" }
  /humanize:
    post:
      tags: [Runs]
      operationId: humanize
      summary: Start a run
      description: |
        Rewrites a text so it reads naturally and keeps its meaning and facts, and reads it with both AI checks. The answer is `202` at once with the run; follow it with `GET /jobs/{id}`, a webhook, or a `callback_url`.

        Every run uses HumanBlend's engine at 1 credit per word. An older integration may still send `mode`; its old values are accepted and run the same engine.
      x-scope: humanize
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [text]
              properties:
                text: { $ref: "#/components/schemas/Text" }
                format: { $ref: "#/components/schemas/Format" }
                spelling: { $ref: "#/components/schemas/Spelling" }
                metadata: { $ref: "#/components/schemas/Metadata" }
                seo: { $ref: "#/components/schemas/Seo" }
                callback_url: { $ref: "#/components/schemas/CallbackUrl" }
                mode:
                  type: string
                  deprecated: true
                  description: Optional and ignored. `default`, `one`, `standard` and `ultra` are accepted and run the same engine; any other value is `400 unknown_mode`.
      responses:
        "202":
          description: The run was accepted. `Retry-After` says when to look again.
          headers:
            Retry-After: { schema: { type: integer }, description: Seconds until you should poll. }
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Job" }
        "200":
          description: The same `Idempotency-Key` and text as an earlier call; the first run is returned instead of a second one.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Job" }
        "400": { $ref: "#/components/responses/ValidationFailed" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "402": { $ref: "#/components/responses/PaymentRequired" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "409": { $ref: "#/components/responses/Conflict" }
        "422": { $ref: "#/components/responses/Unprocessable" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /jobs:
    get:
      tags: [Runs]
      operationId: listJobs
      summary: List runs
      description: Your runs, newest first. A list carries no texts.
      x-scope: read
      parameters:
        - { name: status, in: query, schema: { $ref: "#/components/schemas/JobStatus" } }
        - { name: since, in: query, description: Only runs created at or after this time., schema: { type: string, format: date-time } }
        - { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100 } }
        - { name: cursor, in: query, description: "`next_cursor` from the previous page.", schema: { type: string } }
      responses:
        "200":
          description: A page of runs.
          content:
            application/json:
              schema:
                type: object
                required: [object, data, next_cursor]
                properties:
                  object: { type: string, const: list }
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/Job" }
                  next_cursor: { type: [string, "null"] }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /jobs/{id}:
    get:
      tags: [Runs]
      operationId: getJob
      summary: Get a run
      description: The run, and once it has succeeded, its `output`. While it is queued or processing, `Retry-After` says when to look again.
      x-scope: read
      parameters:
        - $ref: "#/components/parameters/Id"
      responses:
        "200":
          description: The run.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/JobWithText" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /jobs/{id}/cancel:
    post:
      tags: [Runs]
      operationId: cancelJob
      summary: Cancel a run
      description: Cancels a run that has not finished and gives its held credits back.
      x-scope: humanize
      parameters:
        - $ref: "#/components/parameters/Id"
      responses:
        "200":
          description: The run, now cancelled (or already finished).
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Job" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /jobs/{id}/content:
    delete:
      tags: [Runs]
      operationId: deleteJobContent
      summary: Delete a run's text
      description: Deletes the input and output text now and keeps the record (its words, credits and scores).
      x-scope: humanize
      parameters:
        - $ref: "#/components/parameters/Id"
      responses:
        "204": { description: Deleted. }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /detect:
    post:
      tags: [AI checks]
      operationId: detect
      summary: Check a text
      description: Reads a text with both AI checks (`standard` and `strict`) and returns both readings. It costs credits per word. `202` while the readings are still coming, `200` when done.
      x-scope: detect
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [text]
              properties:
                text: { $ref: "#/components/schemas/Text" }
                format: { $ref: "#/components/schemas/Format" }
                callback_url: { $ref: "#/components/schemas/CallbackUrl" }
      responses:
        "200":
          description: The check is done.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Detection" }
        "202":
          description: The check was accepted and is still running.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Detection" }
        "400": { $ref: "#/components/responses/ValidationFailed" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "402": { $ref: "#/components/responses/PaymentRequired" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "409": { $ref: "#/components/responses/Conflict" }
        "422": { $ref: "#/components/responses/Unprocessable" }
        "429": { $ref: "#/components/responses/RateLimited" }
        "503": { $ref: "#/components/responses/Unavailable" }
  /detections/{id}:
    get:
      tags: [AI checks]
      operationId: getDetection
      summary: Get a check
      description: A check and, once done, both readings.
      x-scope: read
      parameters:
        - $ref: "#/components/parameters/Id"
      responses:
        "200":
          description: The check.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Detection" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /batches:
    post:
      tags: [Bulk runs]
      operationId: createBatch
      summary: Start a bulk run
      description: |
        Up to 100 documents. Every document is checked and every credit is held before any run starts: if one document is invalid (`422 batch_invalid`) or your credits do not cover all of them (`402 insufficient_credits` with `short_by`), nothing runs and nothing is charged.

        Bulk runs queue behind real-time runs and do not use your plan's runs-at-once. One batch runs at a time on Entry to Pro, three on Agency and above.
      x-scope: batches
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [documents]
              properties:
                documents:
                  type: array
                  minItems: 1
                  maxItems: 100
                  items:
                    type: object
                    required: [text]
                    properties:
                      text: { $ref: "#/components/schemas/Text" }
                      format: { $ref: "#/components/schemas/Format" }
                      spelling: { $ref: "#/components/schemas/Spelling" }
                      metadata: { $ref: "#/components/schemas/Metadata" }
                metadata: { $ref: "#/components/schemas/Metadata" }
                callback_url: { $ref: "#/components/schemas/CallbackUrl" }
      responses:
        "202":
          description: The batch was accepted.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Batch" }
        "200":
          description: The same `Idempotency-Key` and body as an earlier call; the first batch is returned.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Batch" }
        "400": { $ref: "#/components/responses/ValidationFailed" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "402": { $ref: "#/components/responses/PaymentRequired" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "409": { $ref: "#/components/responses/Conflict" }
        "422": { $ref: "#/components/responses/Unprocessable" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /batches/{id}:
    get:
      tags: [Bulk runs]
      operationId: getBatch
      summary: Get a bulk run
      description: The batch's status, counts and credits.
      x-scope: read
      parameters:
        - $ref: "#/components/parameters/Id"
      responses:
        "200":
          description: The batch.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Batch" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /batches/{id}/jobs:
    get:
      tags: [Bulk runs]
      operationId: listBatchJobs
      summary: List a bulk run's documents
      description: Each document, in the order sent, with its text once done.
      x-scope: read
      parameters:
        - $ref: "#/components/parameters/Id"
        - { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 25 } }
        - { name: cursor, in: query, description: "`next_cursor` from the previous page.", schema: { type: string } }
      responses:
        "200":
          description: A page of documents.
          content:
            application/json:
              schema:
                type: object
                required: [object, data, next_cursor]
                properties:
                  object: { type: string, const: list }
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/JobWithText" }
                  next_cursor: { type: [string, "null"] }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /batches/{id}/cancel:
    post:
      tags: [Bulk runs]
      operationId: cancelBatch
      summary: Cancel a bulk run
      description: Cancels the documents that have not finished yet. `cancelled` is how many were cancelled.
      x-scope: batches
      parameters:
        - $ref: "#/components/parameters/Id"
      responses:
        "200":
          description: The batch, with how many documents were cancelled.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/Batch"
                  - type: object
                    properties:
                      cancelled: { type: integer }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
        "429": { $ref: "#/components/responses/RateLimited" }
  /webhooks:
    get:
      tags: [Webhooks]
      operationId: listWebhooks
      summary: List webhook endpoints
      x-scope: webhooks
      responses:
        "200":
          description: Your endpoints.
          content:
            application/json:
              schema:
                type: object
                required: [object, data]
                properties:
                  object: { type: string, const: list }
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/WebhookEndpoint" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
    post:
      tags: [Webhooks]
      operationId: createWebhook
      summary: Create a webhook endpoint
      description: The URL must be https on a public host. The signing secret is returned here once. Endpoints made on the Developers page keep a cap of 5; endpoints made through the API count against a cap of 50.
      x-scope: webhooks
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [url, events]
              properties:
                url: { type: string, format: uri, maxLength: 2000 }
                events:
                  type: array
                  minItems: 1
                  maxItems: 10
                  items: { $ref: "#/components/schemas/WebhookEvent" }
                source:
                  type: string
                  enum: [zapier, make, n8n, api]
                  default: api
                  description: Which tool created the endpoint. The Developers page lists endpoints by source. Endpoints made on the Developers page read back as `app`, which cannot be sent.
                label:
                  type: string
                  maxLength: 100
                  description: A name for the endpoint, such as "Run finished (Zap 123)".
      responses:
        "201":
          description: The endpoint, with its secret.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/WebhookEndpoint"
                  - type: object
                    required: [secret]
                    properties:
                      secret: { type: string, description: The signing secret, shown once. }
        "400": { $ref: "#/components/responses/ValidationFailed" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "409":
          description: "`endpoint_limit`: the account has reached its cap of webhook endpoints."
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Error" }
  /webhooks/{id}:
    patch:
      tags: [Webhooks]
      operationId: updateWebhook
      summary: Update a webhook endpoint
      description: Change the URL or events, or turn the endpoint on or off. Setting `enabled` to true clears a failure switch-off.
      x-scope: webhooks
      parameters:
        - $ref: "#/components/parameters/Id"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url: { type: string, format: uri, maxLength: 2000 }
                events:
                  type: array
                  minItems: 1
                  maxItems: 10
                  items: { $ref: "#/components/schemas/WebhookEvent" }
                enabled: { type: boolean }
      responses:
        "200":
          description: The endpoint.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/WebhookEndpoint" }
        "400": { $ref: "#/components/responses/ValidationFailed" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
    delete:
      tags: [Webhooks]
      operationId: deleteWebhook
      summary: Delete a webhook endpoint
      x-scope: webhooks
      parameters:
        - $ref: "#/components/parameters/Id"
      responses:
        "204": { description: Deleted. }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /webhooks/{id}/rotate:
    post:
      tags: [Webhooks]
      operationId: rotateWebhookSecret
      summary: Rotate a signing secret
      description: Returns a new secret, shown once. The old secret keeps signing beside it for 24 hours, so you can switch over without losing events.
      x-scope: webhooks
      parameters:
        - $ref: "#/components/parameters/Id"
      responses:
        "200":
          description: The endpoint, with its new secret.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/WebhookEndpoint"
                  - type: object
                    required: [secret]
                    properties:
                      secret: { type: string }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /webhooks/{id}/test:
    post:
      tags: [Webhooks]
      operationId: testWebhook
      summary: Send a test event
      description: Sends a `webhook.test` event to the endpoint now.
      x-scope: webhooks
      parameters:
        - $ref: "#/components/parameters/Id"
      responses:
        "202":
          description: The test delivery.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/WebhookDelivery" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
  /webhooks/{id}/deliveries:
    get:
      tags: [Webhooks]
      operationId: listWebhookDeliveries
      summary: List deliveries
      description: The endpoint's deliveries of the last 30 days, newest first, up to 50.
      x-scope: webhooks
      parameters:
        - $ref: "#/components/parameters/Id"
      responses:
        "200":
          description: The deliveries.
          content:
            application/json:
              schema:
                type: object
                required: [object, data]
                properties:
                  object: { type: string, const: list }
                  data:
                    type: array
                    items: { $ref: "#/components/schemas/WebhookDelivery" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "403": { $ref: "#/components/responses/Forbidden" }
        "404": { $ref: "#/components/responses/NotFound" }
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: |
        A HumanBlend API key from the Developers page (app.humanblended.com/app/developers), sent as `Authorization: Bearer <key>`. A key belongs to one account and has scopes: `read`, `humanize`, `detect`, `batches`, `webhooks` and `billing`.
  parameters:
    Id:
      name: id
      in: path
      required: true
      schema: { type: string, format: uuid }
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: 8 to 255 characters. Sending the same key again returns the first result instead of starting a second run. The same key with a different body is refused with a 409.
      schema: { type: string, minLength: 8, maxLength: 255 }
  responses:
    Unauthorized:
      description: "`missing_api_key` or `invalid_api_key`."
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    Forbidden:
      description: "`plan_required` (the account has no plan; `details.plans_url` opens the plan choice and `details.trial` says whether the card trial is open), `insufficient_scope`, `account_frozen` or `api_not_available`."
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    ValidationFailed:
      description: "`validation_failed` (`details.fields` lists each problem), `idempotency_key_required` or `unknown_mode`."
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    PaymentRequired:
      description: "`insufficient_credits` (`details.needed`, `available`, `short_by`) or `key_cap_reached`."
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    Conflict:
      description: "`idempotency_conflict` (the same Idempotency-Key with a different text), `idempotency_key_reused` (a batch: the same key with a different body) or `batch_limit`."
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    Unprocessable:
      description: "`text_too_short`, `text_too_long`, `too_many_characters` or `batch_invalid` (`details.problems` by position)."
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    NotFound:
      description: "`not_found`."
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    RateLimited:
      description: "`rate_limited` or `concurrency_limit`. `Retry-After` says when to try again."
      headers:
        Retry-After: { schema: { type: integer } }
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    Unavailable:
      description: "`auth_unavailable`, `detector_unavailable` or `submissions_paused`. Try again shortly."
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
  schemas:
    Error:
      type: object
      required: [error, code]
      properties:
        error: { type: string, description: A sentence you can show to a person. }
        code: { type: string, description: Stable. Branch on this, not on the sentence. }
        details: { type: object, additionalProperties: true }
        request_id: { type: string, description: Quote this when you contact support. }
    Text:
      type: string
      minLength: 1
      maxLength: 200000
      description: The text. Your plan's words-per-run limit applies.
    Format:
      type: [string, "null"]
      enum: [text, markdown, null]
      description: "`markdown` keeps headings, lists, links and code as they are. Default `text`."
    Spelling:
      type: [string, "null"]
      enum: [us, gb, auto, null]
      description: Which English spelling to use. `auto` follows the text.
    Metadata:
      type: [object, "null"]
      maxProperties: 10
      additionalProperties: { type: string, maxLength: 200 }
      description: Up to 10 labels of your own, keys up to 40 characters, values up to 200. They come back on the run and in webhooks.
    Seo:
      type: [object, "null"]
      required: [keyword]
      properties:
        keyword: { type: string, minLength: 2, maxLength: 80 }
        location: { type: string, maxLength: 80, description: "Default `United States`." }
        keywords:
          type: array
          maxItems: 19
          items: { type: string, minLength: 2, maxLength: 80 }
          description: Secondary keywords.
      description: Also optimize the text for a search keyword. Uses one of the account's SEO articles (`GET /account` shows how many are left) and takes longer.
    CallbackUrl:
      type: string
      format: uri
      maxLength: 2000
      description: |
        An https URL on a public host (the same checks as a webhook endpoint; a bad one is `400 validation_failed` with a message starting "Callback URLs"). When the run, check or batch reaches a final state, HumanBlend sends one `POST` to it. See "Webhooks and callbacks". The job echoes `callback_url: "set"` and never the URL.
    JobStatus:
      type: string
      enum: [queued, processing, succeeded, failed, cancelled, expired]
    Score:
      type: object
      required: [score, verdict, label, status]
      properties:
        score: { type: [integer, "null"], minimum: 0, maximum: 100, description: The AI score, 0 to 100; null until `status` is `done`. }
        verdict: { type: [string, "null"], enum: [human, mixed, ai, null] }
        label: { type: [string, "null"], description: "A sentence for the score, such as \"Likely human\"." }
        status: { type: string, enum: [done, pending, unavailable], description: "`pending`: still reading. `unavailable`: the check could not read the text." }
    Scores:
      type: object
      description: The two AI checks. A quality reading to review the text with, not a guarantee about how any other tool will judge it.
      properties:
        standard: { oneOf: [{ $ref: "#/components/schemas/Score" }, { type: "null" }] }
        strict: { oneOf: [{ $ref: "#/components/schemas/Score" }, { type: "null" }] }
    Job:
      type: object
      required: [id, object, status, words, credits_held, credits_charged, created_at, finished_at, source, batch_id, metadata, scores, error, content_deleted]
      properties:
        id: { type: string, format: uuid }
        object: { type: string, const: job }
        status: { $ref: "#/components/schemas/JobStatus" }
        mode: { type: [string, "null"], description: Always `default`. }
        words: { type: integer }
        credits_held: { type: integer }
        credits_charged: { type: [integer, "null"] }
        created_at: { type: string, format: date-time }
        finished_at: { type: [string, "null"], format: date-time }
        source: { type: string, description: "`api`, `mcp` or `app`." }
        batch_id: { type: [string, "null"], format: uuid }
        metadata: { $ref: "#/components/schemas/Metadata" }
        scores: { oneOf: [{ $ref: "#/components/schemas/Scores" }, { type: "null" }] }
        error:
          type: [object, "null"]
          properties:
            code: { type: string }
            message: { type: string }
        content_deleted: { type: boolean, description: The text has been deleted (by you or by retention). }
        callback_url:
          type: [string, "null"]
          enum: [set, null]
          description: "`set` when the run has a callback URL, else null. The URL is never shown."
        warnings:
          type: array
          items: { type: object }
          description: What about the text may affect the result without stopping the run.
    JobWithText:
      allOf:
        - $ref: "#/components/schemas/Job"
        - type: object
          properties:
            output: { type: [string, "null"], description: The finished text, once the run has succeeded. }
            output_words: { type: [integer, "null"] }
            format: { type: string, enum: [text, markdown] }
            spelling:
              type: [object, "null"]
              properties:
                used: { type: string, enum: [us, gb] }
                auto: { type: boolean }
    Detection:
      type: object
      required: [id, object, status, words, credits, created_at, finished_at, scores, error]
      properties:
        id: { type: string, format: uuid }
        object: { type: string, const: detection }
        status: { type: string }
        words: { type: integer }
        credits: { type: integer }
        created_at: { type: string, format: date-time }
        finished_at: { type: [string, "null"], format: date-time }
        scores: { $ref: "#/components/schemas/Scores" }
        error: { type: [object, "null"] }
        callback_url:
          type: [string, "null"]
          enum: [set, null]
          description: "`set` when the check has a callback URL, else null."
    Batch:
      type: object
      required: [id, object, status, documents, counts, credits_held, credits_charged, created_at, finished_at, source, metadata]
      properties:
        id: { type: string, format: uuid }
        object: { type: string, const: batch }
        status: { type: string }
        documents: { type: integer }
        counts: { type: object, additionalProperties: { type: integer }, description: How many documents are in each status. }
        credits_held: { type: integer }
        credits_charged: { type: integer }
        created_at: { type: string, format: date-time }
        finished_at: { type: [string, "null"], format: date-time }
        source: { type: string }
        metadata: { $ref: "#/components/schemas/Metadata" }
        callback_url:
          type: [string, "null"]
          enum: [set, null]
          description: "`set` when the batch has a callback URL, else null."
    Estimate:
      type: object
      properties:
        object: { type: string, const: estimate }
        mode: { type: string }
        words: { type: integer }
        credits: { type: integer }
        allowed: { type: boolean }
        available: { type: integer }
        short_by: { type: integer }
        reasons: { type: array, items: { type: string } }
    Account:
      type: object
      properties:
        object: { type: string, const: account }
        id: { type: string }
        plan:
          type: object
          properties:
            kind: { type: string }
            code: { type: [string, "null"] }
            name: { type: [string, "null"] }
        plan_required:
          type: boolean
          description: |-
            True when the account has no plan. With no plan, `plan` is `{ kind: "none", code: null, name: "None" }` (or `{ kind: "free", code: "free_run", name: "Free run (in the app)" }` while the app's free run is unused). Only `GET /account`, `POST /estimate`, `GET /plans`, `POST /checkout` and `POST /billing/portal` work then.
        plans_url:
          type: string
          format: uri
          description: Opens the plan choice in the app (the plans section of Usage).
        credits:
          type: object
          properties:
            available: { type: integer }
            held: { type: integer }
        seo_articles: { type: integer }
        limits: { type: object, additionalProperties: true }
        key:
          type: object
          properties:
            id: { type: [string, "null"] }
            scopes: { type: array, items: { type: string } }
            monthly_credit_cap: { type: [integer, "null"] }
            used_this_month: { type: [integer, "null"] }
    TrialOffer:
      type: object
      required: [available, days, credits]
      properties:
        available: { type: boolean, description: "Whether this account can start the card trial. False when the trial is off, the account had a subscription, or the key was made by a member." }
        days: { type: integer }
        credits: { type: [integer, "null"], description: "The trial's credits; null when the terms are a share of the plan." }
    Plan:
      type: object
      required: [code, name, interval, price_cents, currency, credits_per_month, max_words_per_run, runs_at_once]
      properties:
        code: { type: string }
        name: { type: string }
        interval: { type: string, enum: [month, year] }
        price_cents: { type: integer, description: The price for one interval, in cents. }
        currency: { type: string, examples: [usd] }
        credits_per_month: { type: integer }
        max_words_per_run: { type: integer }
        runs_at_once: { type: integer }
    WebhookEvent:
      type: string
      enum: [job.succeeded, job.failed, job.cancelled, detection.completed, batch.completed, credits.low]
    WebhookEndpoint:
      type: object
      required: [id, url, events, enabled, created_at]
      properties:
        id: { type: string, format: uuid }
        url: { type: string, format: uri }
        events:
          type: array
          items: { $ref: "#/components/schemas/WebhookEvent" }
        enabled: { type: boolean }
        disabled_reason: { type: [string, "null"] }
        created_at: { type: string, format: date-time }
        rotated_at: { type: [string, "null"], format: date-time }
        failing_since: { type: [string, "null"], format: date-time }
        source:
          type: string
          enum: [zapier, make, n8n, api, app]
          description: Where the endpoint was made. `app` is the Developers page.
        label:
          type: [string, "null"]
    WebhookDelivery:
      type: object
      properties:
        id: { type: string }
        event: { type: string }
        object_id: { type: string }
        status: { type: string, description: "`pending`, `delivered` or `failed`." }
        attempts: { type: integer }
        last_status_code: { type: [integer, "null"] }
        last_error: { type: [string, "null"] }
        created_at: { type: string, format: date-time }
        delivered_at: { type: [string, "null"], format: date-time }
        next_attempt_at: { type: [string, "null"], format: date-time }
