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

# Attach a target to this group

> `target_ref` must match the group's `target_type`: an IP address
for `ip`, a compute instance id for `instance`. A `function`
group takes no targets yet, and a `pool`-mode group takes its
backends from the instance pool — attaching to either is an
error rather than a row nothing will ever route to.




## OpenAPI

````yaml /api-reference/specs/loadbalancer.yaml post /v1/target-groups/{id}/targets
openapi: 3.0.3
info:
  title: Basaltic Load Balancer API
  version: 1.0.0
  description: |
    Managed load balancers: listeners, target pools, health checks and the
    TLS certificates a listener terminates.
  contact:
    name: Basaltic Support
    email: ping@basaltic.sh
  license:
    name: Proprietary
    url: https://basaltic.sh/terms
servers:
  - url: https://loadbalancer.{region}.basaltic.sh
    description: Regional API endpoint
    variables:
      region:
        default: sa-saopaulo-1
        description: Region code
security:
  - SignatureAuth: []
paths:
  /v1/target-groups/{id}/targets:
    post:
      tags:
        - Load Balancers
      summary: Attach a target to this group
      description: |
        `target_ref` must match the group's `target_type`: an IP address
        for `ip`, a compute instance id for `instance`. A `function`
        group takes no targets yet, and a `pool`-mode group takes its
        backends from the instance pool — attaching to either is an
        error rather than a row nothing will ever route to.
      operationId: attachTarget
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            example: b8c9d0e1-f2a3-4456-b7c8-d9e0f1a2b3c4
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AttachTargetRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TargetResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      description: >-
        Optional client-generated key that makes a create replay-safe. Retrying
        a request with the same key returns the original outcome verbatim
        instead of creating a duplicate resource. Reusing a key with a different
        request body is rejected (422); a request whose key is still being
        processed returns 409. Records are honored for 24 hours. Use a UUID or
        similarly unique token.
      required: false
      schema:
        type: string
        maxLength: 255
      example: 550e8400-e29b-41d4-a716-446655440000
  schemas:
    AttachTargetRequest:
      type: object
      required:
        - target_ref
      properties:
        target_ref:
          type: string
          example: d0e1f2a3-b4c5-4678-d9e0-f1a2b3c4d5e6
          description: |
            Must match the group's target_type: an IP address for `ip`,
            a compute instance id for `instance`. An `ip` ref has to be
            a routable unicast address — loopback, link-local (including
            the 169.254.169.254 metadata endpoint), multicast, and
            unspecified addresses are rejected.
        port:
          type: integer
          minimum: 1
          maximum: 65535
          example: 8080
    TargetResponse:
      type: object
      properties:
        target:
          $ref: '#/components/schemas/Target'
    Target:
      type: object
      required:
        - id
        - target_group_id
        - target_ref
        - health
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
          example: c9d0e1f2-a3b4-4567-c8d9-e0f1a2b3c4d5
        target_group_id:
          type: string
          format: uuid
          example: b8c9d0e1-f2a3-4456-b7c8-d9e0f1a2b3c4
        target_ref:
          type: string
          description: |
            IP address (target_type=ip) or compute instance id
            (target_type=instance). Stored in canonical form, so the
            spelling here may differ from the one you sent.
          example: d0e1f2a3-b4c5-4678-d9e0-f1a2b3c4d5e6
        port:
          type: integer
          minimum: 1
          maximum: 65535
          example: 8080
        health:
          type: string
          enum:
            - initial
            - healthy
            - unhealthy
            - draining
          example: healthy
        last_seen_at:
          type: string
          format: date-time
          example: '2026-01-15T09:31:00Z'
        created_at:
          type: string
          format: date-time
          example: '2026-01-15T09:30:00Z'
        updated_at:
          type: string
          format: date-time
          example: '2026-01-15T09:30:00Z'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - request_id
          properties:
            code:
              type: string
              description: Error code identifying the type of error
              example: INVALID_INPUT
            message:
              type: string
              description: Human-readable error message
              example: Invalid request parameters
            request_id:
              type: string
              format: uuid
              description: Request ID for debugging
              example: 550e8400-e29b-41d4-a716-446655440000
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: INVALID_INPUT
              message: Invalid request parameters
              request_id: 550e8400-e29b-41d4-a716-446655440000
    Unauthorized:
      description: Authentication required or token invalid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: UNAUTHORIZED
              message: Authentication required
              request_id: 550e8400-e29b-41d4-a716-446655440000
    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: ACCESS_DENIED
              message: You don't have permission to perform this action
              request_id: 550e8400-e29b-41d4-a716-446655440000
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: NOT_FOUND
              message: Resource not found
              request_id: 550e8400-e29b-41d4-a716-446655440000
    Conflict:
      description: Resource conflict (e.g., already exists, invalid state)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: CONFLICT
              message: Resource with this name already exists
              request_id: 550e8400-e29b-41d4-a716-446655440000
    UnprocessableEntity:
      description: |
        The request is well-formed but cannot be processed as sent. On the
        operations that accept `Idempotency-Key` this is the key-reuse case: the
        key was first seen with a different request payload, so replaying the
        stored outcome would answer a question the caller did not ask.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: IDEMPOTENCY_KEY_REUSED
              message: >-
                This Idempotency-Key was already used with a different request
                payload
              request_id: 550e8400-e29b-41d4-a716-446655440000
  securitySchemes:
    SignatureAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >
        Request signing with an access key issued to a service account. An

        HMAC-SHA256 over a canonical form of the request, close to AWS SigV4.

        The `basaltic` CLI signs for you.


        Send `Authorization`, `X-Date` (UTC, `YYYYMMDDTHHMMSSZ`) and `X-Nonce`

        (random per request); add `X-Content-Sha256` to bind a body, and

        `X-Amz-Security-Token` when using temporary credentials.


        ```

        Authorization: BASALTIC-HMAC-SHA256
        Credential=<access_key_id>/<date>/<region>/basaltic/basaltic_request,
        SignedHeaders=host;x-date;x-nonce, Signature=<hex>

        ```


        `<region>` is the region code you are calling, or `global` for the
        global

        services. A signature is valid for 5 minutes from `X-Date`, and mutating

        requests are replay-guarded on the nonce.


        **Full signing procedure, including a working implementation:**

        https://docs.basaltic.sh/authentication


        ## Rate limits

        There is no global request budget. A limit applies only where an

        operation documents a `429`, and that operation says what it counts.

        Those responses carry `X-RateLimit-Limit`, `X-RateLimit-Remaining`,

        `X-RateLimit-Reset` and, on a `429`, `Retry-After` — read them rather

        than hard-coding a number. Retrying before `Retry-After` is refused and

        extends the window. Everything else is bounded by quota, not by request

        rate.

````