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

# Deploy a Worker

> Deploys a new worker. A node in the given location is picked automatically.

Workers are billed by measured usage, and the first hour is charged against your balance, so the deploy is rejected outright when the balance is below the minimum. Call `GET /workers/deploy-requirements` first to see that minimum and how many workers your account level still allows.

What `git_repository` holds depends on `git_source`:

- `public`: a publicly reachable git URL.
- `github`: a URL on a private repository of the GitHub account linked to your panel account. The OAuth flow only exists in the panel, so an account that has never linked GitHub is answered with `GITHUB_NOT_CONNECTED`.
- `template` / `database`: the `id` of an entry from `GET /workers/templates`, not a URL.

The worker comes back in `pending` and is built in the background. Poll `GET /workers/{worker}/status` until it reports `active`.



## OpenAPI

````yaml POST /workers
openapi: 3.0.3
info:
  title: CloudBlast API
  description: >-
    The CloudBlast V2 API provides a modern RESTful interface for managing your
    cloud infrastructure programmatically. All responses follow a consistent `{
    "data": ... }` or `{ "error": ... }` format.
  version: 2.0.0
servers:
  - url: https://console.cloudblast.io/api/v2
    description: Production
security:
  - bearerAuth: []
paths:
  /workers:
    post:
      tags:
        - Workers
      summary: Deploy a worker
      description: >-
        Deploys a new worker. A node in the given location is picked
        automatically.


        Workers are billed by measured usage, and the first hour is charged
        against your balance, so the deploy is rejected outright when the
        balance is below the minimum. Call `GET /workers/deploy-requirements`
        first to see that minimum and how many workers your account level still
        allows.


        What `git_repository` holds depends on `git_source`:


        - `public`: a publicly reachable git URL.

        - `github`: a URL on a private repository of the GitHub account linked
        to your panel account. The OAuth flow only exists in the panel, so an
        account that has never linked GitHub is answered with
        `GITHUB_NOT_CONNECTED`.

        - `template` / `database`: the `id` of an entry from `GET
        /workers/templates`, not a URL.


        The worker comes back in `pending` and is built in the background. Poll
        `GET /workers/{worker}/status` until it reports `active`.
      operationId: createWorker
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWorkerRequest'
      responses:
        '201':
          description: Worker accepted and queued for provisioning
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Worker'
        '400':
          description: >-
            Your account level allows 2 workers. Delete a worker or raise your
            account level to deploy more.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: WORKER_LIMIT_REACHED
                  message: >-
                    Your account level allows 2 workers. Delete a worker or
                    raise your account level to deploy more.
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '402':
          description: >-
            Insufficient balance to deploy a Worker. At least 0.08 EUR is
            required to cover its first hour of usage. Please top up first.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: INSUFFICIENT_BALANCE
                  message: >-
                    Insufficient balance to deploy a Worker. At least 0.08 EUR
                    is required to cover its first hour of usage. Please top up
                    first.
        '403':
          description: Worker service sales are currently disabled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: WORKERS_DISABLED
                  message: Worker service sales are currently disabled.
        '404':
          description: That location is not available for workers.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: LOCATION_UNAVAILABLE
                  message: That location is not available for workers.
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    CreateWorkerRequest:
      type: object
      required:
        - location_id
        - name
        - git_repository
      properties:
        location_id:
          type: integer
          description: From `GET /workers/locations`.
          example: 1
        name:
          type: string
          maxLength: 191
          example: api-worker
        git_repository:
          type: string
          maxLength: 500
          description: >-
            Repository URL, or a template `id` when `git_source` is `template`
            or `database`.
          example: https://github.com/example/app
        git_source:
          type: string
          enum:
            - public
            - github
            - template
            - database
          default: public
          description: '`github` requires a GitHub account linked in the panel.'
        git_branch:
          type: string
          maxLength: 191
          nullable: true
          default: main
        build_pack:
          type: string
          enum:
            - nixpacks
            - static
            - dockerfile
          default: nixpacks
        ports_exposes:
          type: string
          maxLength: 64
          nullable: true
          default: '3000'
          description: Port your application listens on.
        base_directory:
          type: string
          maxLength: 255
          nullable: true
        publish_directory:
          type: string
          maxLength: 255
          nullable: true
          description: Directory to serve for a `static` build.
        install_command:
          type: string
          maxLength: 1000
          nullable: true
        build_command:
          type: string
          maxLength: 1000
          nullable: true
        start_command:
          type: string
          maxLength: 1000
          nullable: true
        is_spa:
          type: boolean
          default: false
          description: Route unknown paths of a static build to the index.
    Worker:
      type: object
      properties:
        uuid:
          type: string
          format: uuid
          description: Worker handle. Use this as the `{worker}` path parameter.
          example: 7c9e6679-7425-40de-944b-e07fc1f90ae7
        name:
          type: string
          example: api-worker
        status:
          type: string
          description: >-
            Lifecycle state. `provisioning` means the first build is running;
            `failed` means it did not come up and can be retried with a `deploy`
            action.
          enum:
            - pending
            - provisioning
            - active
            - suspended
            - abuse_suspended
            - cancelled
            - deleting
            - failed
          example: active
        runtime_status:
          type: string
          nullable: true
          description: Container state, such as `running`, `starting` or `exited`.
          example: running
        runtime_status_at:
          type: string
          format: date-time
          nullable: true
          description: When the container state was last read.
        provisioned:
          type: boolean
          description: False until the first build has produced an application.
          example: true
        last_deployment_status:
          type: string
          nullable: true
          description: >-
            Status of the most recent build, such as `queued`, `in_progress`,
            `finished` or `failed`.
          example: finished
        last_deployment_at:
          type: string
          format: date-time
          nullable: true
        last_error:
          type: string
          nullable: true
          description: >-
            Why the last action failed, in plain language. `null` when the
            worker is healthy.
        fqdn:
          type: string
          nullable: true
          description: Hostname the worker is served on, once it has one.
          example: api-worker.workers.cloudblast.io
        location_id:
          type: integer
          description: Worker location, from `GET /workers/locations`.
          example: 1
        git_source:
          type: string
          enum:
            - public
            - github
            - template
            - database
          example: public
        git_repository:
          type: string
          description: >-
            Repository URL, or the template id for a `template` or `database`
            worker.
          example: https://github.com/example/app
        git_branch:
          type: string
          nullable: true
          description: Branch that is built.
          example: main
        build_pack:
          type: string
          enum:
            - nixpacks
            - static
            - dockerfile
          example: nixpacks
        ports_exposes:
          type: string
          nullable: true
          description: Port the container listens on.
          example: '3000'
        base_directory:
          type: string
          nullable: true
          description: Directory inside the repository the build runs from.
        publish_directory:
          type: string
          nullable: true
          description: Directory served for a `static` build.
        install_command:
          type: string
          nullable: true
          description: Overrides the detected install step.
        build_command:
          type: string
          nullable: true
          description: Overrides the detected build step.
        start_command:
          type: string
          nullable: true
          description: Overrides the detected start command.
        is_spa:
          type: boolean
          description: >-
            Serve a static build as a single-page app, routing unknown paths to
            the index.
          example: false
        limits:
          type: object
          description: >-
            Hard container caps, stamped at creation from the account level. A
            worker keeps the limits it was created with even after the account
            levels up.
          properties:
            cpu:
              type: number
              nullable: true
              description: Cores
              example: 1
            memory_mb:
              type: integer
              nullable: true
              example: 1024
            disk_mb:
              type: integer
              nullable: true
              example: 5120
        usage:
          type: object
          description: Last measured consumption. `null` before anything has been measured.
          properties:
            cpu_percent:
              type: number
              nullable: true
              example: 3.5
            memory_mb:
              type: integer
              nullable: true
              example: 184
            disk_mb:
              type: integer
              nullable: true
              example: 612
        billing_type:
          type: string
          description: Workers are billed by measured usage, charged hourly.
          enum:
            - hourly
          example: hourly
        suspended_at:
          type: string
          format: date-time
          nullable: true
        suspension_reason:
          type: string
          nullable: true
          description: Why the worker was suspended, when it was.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        location:
          $ref: '#/components/schemas/WorkerLocation'
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code
            message:
              type: string
              description: Human-readable error message
          required:
            - code
            - message
    WorkerLocation:
      type: object
      properties:
        id:
          type: integer
          description: Pass as `location_id` when deploying.
          example: 1
        name:
          type: string
          example: Frankfurt
        short_code:
          type: string
          example: fra
        description:
          type: string
          nullable: true
          example: Germany
        out_of_stock:
          type: boolean
          description: >-
            True when no node in this location can currently take another
            worker.
          example: false
  responses:
    Unauthenticated:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: UNAUTHENTICATED
              message: >-
                Missing or invalid Authorization header. Use: Authorization:
                Bearer <token>
    ValidationError:
      description: Validation failed
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    example: VALIDATION_ERROR
                  message:
                    type: string
                    example: The given data was invalid.
                  details:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                    example:
                      name:
                        - The name field is required.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API token from your CloudBlast account settings. Pass as `Authorization:
        Bearer <token>`.

````