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

# Close a running task

> Queues a close request. Task status may remain running until the worker begins closing.

Send `{}`. The accepted response is `202` with `close_queued`. The task may remain `running` with `closeRequestedAt` set until the worker starts closing it.

A close request is durable even when another operation is active for the wallet. It blocks new opens and resizes while waiting; it cannot interrupt an operation already in progress. Poll until `closing`, then `closed`, or inspect an error.

<RequestExample>
  ```bash cURL theme={null}
  : "${MOBIUS_API_BASE_URL:?Set the API URL from your app}"
  : "${MOBIUS_API_KEY:?Set your API key locally}"
  : "${TASK_ID:?Set the task UUID}"
  : "${IDEMPOTENCY_KEY:?Generate and persist an ID before this mutation}"

  curl -i "$MOBIUS_API_BASE_URL/v1/delta-neutral/tasks/$TASK_ID/close" \
    -H "Authorization: Bearer $MOBIUS_API_KEY" \
    -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
    -H "Content-Type: application/json" \
    -d '{}'
  ```
</RequestExample>


## OpenAPI

````yaml api-reference/openapi.json POST /v1/delta-neutral/tasks/{taskId}/close
openapi: 3.1.1
info:
  title: MöB Delta Neutral API
  version: 1.0.0
  description: >-
    Create and manage paired positions through your bound venue accounts.


    Create an API key in this environment and pass it as a Bearer token. Keys
    grant specific venues and a maximum USD size per leg; they cannot withdraw
    funds. Local and demo deployments can execute real trades.


    All POST requests require a persisted Idempotency-Key. Reuse the same key,
    method, path and equivalent JSON when retrying an uncertain result. Keys are
    scoped to the wallet owner across API keys. HTTP 202 acknowledges a command;
    poll the task to observe execution.


    Authenticated requests are limited to 120 per minute per key. Respect
    Retry-After on 429. Numeric database fields in task responses are decimal
    strings.
servers: []
security:
  - BearerAuth: []
tags:
  - name: Service
  - name: Tasks
  - name: Request logs
paths:
  /v1/delta-neutral/tasks/{taskId}/close:
    parameters:
      - $ref: '#/components/parameters/TaskId'
    post:
      tags:
        - Tasks
      summary: Close a running task
      description: >-
        Queues a close request. Task status may remain running until the worker
        begins closing.
      operationId: closeTask
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmptyCommand'
            example: {}
      responses:
        '202':
          description: Command accepted. Inspect task status for execution.
          content:
            application/json:
              schema:
                type: object
                properties:
                  taskId:
                    type: string
                    format: uuid
                  status:
                    type: string
                    const: close_queued
                required:
                  - taskId
                  - status
              example:
                taskId: 00000000-0000-4000-8000-000000000001
                status: close_queued
          headers:
            X-Request-Id:
              schema:
                type: string
                format: uuid
              description: Support correlation ID.
            X-RateLimit-Limit:
              schema:
                type: integer
                const: 120
            X-RateLimit-Remaining:
              schema:
                type: integer
                minimum: 0
        '400':
          $ref: '#/components/responses/Error400'
        '401':
          $ref: '#/components/responses/Error401'
        '403':
          $ref: '#/components/responses/Error403'
        '404':
          $ref: '#/components/responses/Error404'
        '409':
          $ref: '#/components/responses/Error409'
        '413':
          $ref: '#/components/responses/Error413'
        '415':
          $ref: '#/components/responses/Error415'
        '429':
          $ref: '#/components/responses/Error429'
        '503':
          $ref: '#/components/responses/Error503'
components:
  parameters:
    TaskId:
      name: taskId
      in: path
      required: true
      schema:
        type: string
        format: uuid
        pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: >-
        Persist one ID per intended mutation before sending. Reuse it with the
        same request for retries; different content returns 409.
      schema:
        type: string
        minLength: 1
        maxLength: 128
        pattern: ^[!-~]+$
  schemas:
    EmptyCommand:
      type: object
      additionalProperties: false
    Error:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
      required:
        - error
        - code
      additionalProperties: true
  responses:
    Error400:
      description: Invalid fields, query, JSON or idempotency key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        X-Request-Id:
          schema:
            type: string
            format: uuid
          description: Support correlation ID.
        X-RateLimit-Limit:
          schema:
            type: integer
            const: 120
        X-RateLimit-Remaining:
          schema:
            type: integer
            minimum: 0
    Error401:
      description: Missing, invalid or revoked API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        X-Request-Id:
          schema:
            type: string
            format: uuid
          description: Support correlation ID.
        X-RateLimit-Limit:
          schema:
            type: integer
            const: 120
        X-RateLimit-Remaining:
          schema:
            type: integer
            minimum: 0
    Error403:
      description: Key does not grant the required venues.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        X-Request-Id:
          schema:
            type: string
            format: uuid
          description: Support correlation ID.
        X-RateLimit-Limit:
          schema:
            type: integer
            const: 120
        X-RateLimit-Remaining:
          schema:
            type: integer
            minimum: 0
    Error404:
      description: Task not found or inaccessible.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        X-Request-Id:
          schema:
            type: string
            format: uuid
          description: Support correlation ID.
        X-RateLimit-Limit:
          schema:
            type: integer
            const: 120
        X-RateLimit-Remaining:
          schema:
            type: integer
            minimum: 0
    Error409:
      description: Conflicting state, owner operation, binding or idempotency key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        X-Request-Id:
          schema:
            type: string
            format: uuid
          description: Support correlation ID.
        X-RateLimit-Limit:
          schema:
            type: integer
            const: 120
        X-RateLimit-Remaining:
          schema:
            type: integer
            minimum: 0
    Error413:
      description: JSON body exceeds 16,384 bytes.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        X-Request-Id:
          schema:
            type: string
            format: uuid
          description: Support correlation ID.
        X-RateLimit-Limit:
          schema:
            type: integer
            const: 120
        X-RateLimit-Remaining:
          schema:
            type: integer
            minimum: 0
    Error415:
      description: Content-Type must be application/json.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        X-Request-Id:
          schema:
            type: string
            format: uuid
          description: Support correlation ID.
        X-RateLimit-Limit:
          schema:
            type: integer
            const: 120
        X-RateLimit-Remaining:
          schema:
            type: integer
            minimum: 0
    Error429:
      description: 120 requests per minute per key exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        X-Request-Id:
          schema:
            type: string
            format: uuid
          description: Support correlation ID.
        X-RateLimit-Limit:
          schema:
            type: integer
            const: 120
        X-RateLimit-Remaining:
          schema:
            type: integer
            minimum: 0
        Retry-After:
          schema:
            type: integer
            minimum: 1
          description: Seconds to wait before retrying.
    Error503:
      description: Storage, market data or worker feature unavailable.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        X-Request-Id:
          schema:
            type: string
            format: uuid
          description: Support correlation ID.
        X-RateLimit-Limit:
          schema:
            type: integer
            const: 120
        X-RateLimit-Remaining:
          schema:
            type: integer
            minimum: 0
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key created in this environment: mobius_<uuid>.<secret>. Keep it in
        a local environment variable; never commit it.

````