> ## Documentation Index
> Fetch the complete documentation index at: https://docs.safeconduct.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a captcha task

> Authenticates the key, validates the task, routes it, reserves its price and
queues it. Poll GET /v1/tasks/{id} (or pass ?wait=) for the result. `routing`
lets the request choose its providers; without it, the router decides.




## OpenAPI

````yaml /openapi.yaml post /v1/tasks
openapi: 3.0.3
info:
  title: SafeConduct API
  version: 0.21.0
  description: >
    SafeConduct routes each captcha (later antibot, SERP and proxy) request to
    the best

    provider for its target site, billed from one wallet.


    Compatibility promise (ADR-003): within /v1, changes are additive only: new

    endpoints, new optional fields, new enum values. Clients must ignore unknown
    fields

    and tolerate unknown enum values. Anything else ships as /v2, side by side.


    This is the single source of truth: the dashboard's client is generated from
    it,

    the server is tested against it, and CI rejects breaking changes to it.
servers:
  - url: https://api.safeconduct.ai
security: []
tags:
  - name: captcha
    description: >
      Captcha solving. Create a task, then poll it (or wait on it), or do both
      in one

      call with /v1/tasks/solve. Each task is routed to the best provider for
      its

      site, retried and failed over automatically, and charged only if solved:
      the

      price is reserved when it is created and the unused part released at the
      end.
  - name: billing
    description: Wallet and payments
  - name: stats
    description: Public provider statistics; no key needed
  - name: compat
    description: >
      Drop-in compatible API: the createTask / getTaskResult / getBalance
      methods of

      Anti-Captcha, also used by 2Captcha (v2 API), CapSolver and CapMonster.
      Point an

      existing client at this server's base URL and use a SafeConduct key as
      clientKey.

      Every answer is HTTP 200; errorId > 0 means an error (Anti-Captcha's
      codes;

      errorDescription starts with the SafeConduct error code). taskId is an
      integer,

      or a string for CapSolver-style requests (appId set, or CapSolver's type
      names).

      Also 2Captcha's original in.php / res.php API (GET or POST, form
      parameters):

      plain-text answers (OK|<id>, CAPCHA_NOT_READY, OK|<token>, ERROR_...) or
      JSON

      with json=1.
paths:
  /v1/tasks:
    post:
      tags:
        - captcha
      summary: Create a captcha task
      description: >
        Authenticates the key, validates the task, routes it, reserves its price
        and

        queues it. Poll GET /v1/tasks/{id} (or pass ?wait=) for the result.
        `routing`

        lets the request choose its providers; without it, the router decides.
      operationId: createTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskRequest'
      responses:
        '201':
          description: The task is queued
          headers:
            Location:
              description: The task's URL
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '413':
          $ref: '#/components/responses/BadRequest'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalError'
        '503':
          $ref: '#/components/responses/Unavailable'
      security:
        - bearer: []
        - apiKey: []
components:
  schemas:
    TaskRequest:
      type: object
      required:
        - type
        - websiteURL
        - websiteKey
      additionalProperties: false
      description: Unknown fields are refused. Field names match case-insensitively.
      properties:
        type:
          type: string
          enum:
            - recaptcha_v2
            - recaptcha_v2_enterprise
            - recaptcha_v3
            - recaptcha_v3_enterprise
            - turnstile
        websiteURL:
          type: string
          description: The page showing the captcha (absolute http or https URL)
          example: https://www.ticketmaster.com/event/1
        websiteKey:
          type: string
          description: The sitekey
        isInvisible:
          type: boolean
          description: reCAPTCHA v2 only
        pageAction:
          type: string
          description: reCAPTCHA v3 action, or Turnstile action
        minScore:
          type: number
          minimum: 0.1
          maximum: 0.9
          description: reCAPTCHA v3 only
        enterprisePayload:
          type: object
          description: reCAPTCHA Enterprise only, e.g. {"s":"..."}
        data:
          type: string
          description: Turnstile cData
        pageData:
          type: string
          description: Turnstile chlPageData
        userAgent:
          type: string
        proxy:
          type: string
          description: >-
            Solve through your own proxy, scheme://user:pass@host:port (http,
            https, socks4, socks5)
        routing:
          $ref: '#/components/schemas/TaskRouting'
    Task:
      type: object
      required:
        - id
        - type
        - status
        - reserved
        - createdAt
      properties:
        id:
          type: string
        type:
          type: string
          description: The captcha kind, as in the request
        status:
          type: string
          description: queued, running, ready (solved) or failed. Tolerate new values.
        site:
          type: string
          description: The registrable domain the task was routed for
          example: ticketmaster.com
        policy:
          type: string
          description: The routing policy used (balanced, cheapest, fastest, pinned)
        reserved:
          $ref: '#/components/schemas/USD'
        solution:
          $ref: '#/components/schemas/Solution'
        error:
          $ref: '#/components/schemas/ErrorBody'
        provider:
          type: string
          description: Who solved it
        cost:
          $ref: '#/components/schemas/USD'
        attempts:
          type: array
          description: Every attempt, in order
          items:
            $ref: '#/components/schemas/Attempt'
        createdAt:
          type: string
          format: date-time
        finishedAt:
          type: string
          format: date-time
    TaskRouting:
      type: object
      nullable: true
      additionalProperties: false
      description: >
        Optional: the providers this request wants. Absent or empty, the router
        chooses as

        for every task (the API key's settings, else balanced). The API key's
        exclusions

        and the account's provider rule still apply: naming a provider they rule
        out is

        refused, never quietly sent elsewhere. The customer's own key at a named
        provider

        is used before our account there.
      properties:
        providers:
          type: array
          maxItems: 10
          items:
            type: string
          description: >
            Provider ids (as in GET /v1/stats/providers, e.g. capsolver,
            2captcha),

            tried in this order; case-insensitive. An unknown id is BAD_PARAMS
            with a

            suggestion. These replace the API key's policy and pinned providers
            for this

            task, and the task is not explored.
          example:
            - capsolver
        fallback:
          type: boolean
          default: false
          description: >
            false (default): only the named providers may take the task; if none
            can,

            NO_PROVIDER_AVAILABLE says why for each, and nothing is charged.
            true: the

            named providers first, then the router's own choice of the others.
    USD:
      type: string
      description: An amount in US dollars, as a decimal string
      pattern: ^-?[0-9]+\.[0-9]{2,6}$
      example: '0.0006'
    Solution:
      type: object
      required:
        - token
      description: Present when status is ready
      properties:
        token:
          type: string
          description: Submit this as the captcha response
        userAgent:
          type: string
          description: Reuse this user agent with the token, when present
        cookies:
          type: object
          additionalProperties:
            type: string
    ErrorBody:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: A stable error code (see the error code list); tolerate new values
          example: INSUFFICIENT_BALANCE
        message:
          type: string
    Attempt:
      type: object
      required:
        - 'n'
        - provider
        - durationMs
      properties:
        'n':
          type: integer
        provider:
          type: string
        code:
          type: string
          description: The error code, absent for the solving attempt
        durationMs:
          type: integer
    Error:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorBody'
  responses:
    BadRequest:
      description: >
        The request is invalid (BAD_PARAMS, BAD_URL, UNSUPPORTED_TYPE,
        BAD_SITEKEY,

        BAD_PROXY, ...); 413 when the body is over 64 KiB
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: The API key is missing, invalid or revoked (UNAUTHORIZED)
      headers:
        WWW-Authenticate:
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PaymentRequired:
      description: >-
        The balance is too low (INSUFFICIENT_BALANCE) or a spending cap was
        reached (SPEND_CAP_REACHED)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The key may not use this product (FORBIDDEN)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    TooManyRequests:
      description: >-
        Too many new tasks per second (RATE_LIMITED) or unfinished tasks
        (TOO_MANY_IN_FLIGHT)
      headers:
        Retry-After:
          description: Seconds to wait before retrying
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalError:
      description: Something went wrong on our side (INTERNAL and other ops codes)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unavailable:
      description: >
        No provider can take this task right now (NO_PROVIDER_AVAILABLE, ...).
        When the

        refusal comes from the caller's own choices (the providers `routing`
        names, the

        API key's settings, the account's provider rule), the message says why
        for each.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: 'Your API key: Authorization: Bearer sy_live_...'
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: The same key in a header, for clients that can't set Authorization

````

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