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

# Set Agent Deployment

> Starts, changes, finishes or stops an A/B test on `prod` (agents with deployments on). Send one version at weight 100, or two versions with weights from 1 to 99 that add up to 100. A change that switches which version has the larger share also needs `agents:deploy`. Send `expectedEntries` (what you last saw) to be refused with 409 if someone changed the deployment since.



## OpenAPI

````yaml /api-reference/openapi.json put /v2/voice-agents/{voiceAgentId}/deployment
openapi: 3.0.1
info:
  title: Hamsa API
  description: >-
    The Hamsa API: voice agents and their calls, phone numbers, batch calls and
    knowledge bases; speech to text, text to speech, voices and AI content.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tryhamsa.com
security: []
paths:
  /v2/voice-agents/{voiceAgentId}/deployment:
    put:
      summary: Set agent deployment (A/B test)
      description: >-
        Starts, changes, finishes or stops an A/B test on `prod` (agents with
        deployments on). Send one version at weight 100, or two versions with
        weights from 1 to 99 that add up to 100. A change that switches which
        version has the larger share also needs `agents:deploy`. Send
        `expectedEntries` (what you last saw) to be refused with 409 if someone
        changed the deployment since.
      parameters:
        - in: path
          name: voiceAgentId
          required: true
          description: ID of the voice agent.
          schema:
            type: string
            format: uuid
            example: fc6f158b-24c2-45a6-957b-c57c0a8979b5
        - in: header
          name: Idempotency-Key
          required: false
          description: >-
            Optional, up to 255 characters. Retry with the same key after a
            network error and you get the first answer back instead of the
            change being made twice (kept 10 minutes). Same key with a different
            body: 422 `IdempotencyKeyReused`. While the first request still
            runs: 409 `IdempotencyKeyInProgress`.
          schema:
            type: string
            maxLength: 255
            example: 0b6f3c1e-retry-1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - entries
              properties:
                entries:
                  type: array
                  minItems: 1
                  maxItems: 2
                  items:
                    $ref: '#/components/schemas/AgentVersionDeploymentEntry'
                  description: >-
                    One version at 100, or two versions (1-99 each) adding up to
                    100.
                expectedEntries:
                  type: array
                  minItems: 1
                  items:
                    $ref: '#/components/schemas/AgentVersionDeploymentEntry'
                  description: >-
                    The entries you last saw. If they no longer match, nothing
                    changes and you get 409 `ReleaseStale`.
            examples:
              start:
                summary: Start an A/B test
                value:
                  entries:
                    - versionNumber: 4
                      weight: 90
                    - versionNumber: 5
                      weight: 10
                  expectedEntries:
                    - versionNumber: 4
                      weight: 100
              finish:
                summary: Finish onto the new version
                value:
                  entries:
                    - versionNumber: 5
                      weight: 100
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: success
                  data:
                    type: object
                    description: What production serves.
                    properties:
                      agentId:
                        type: string
                        format: uuid
                        example: fc6f158b-24c2-45a6-957b-c57c0a8979b5
                      entries:
                        type: array
                        items:
                          $ref: '#/components/schemas/AgentVersionDeploymentEntry'
                        description: One version at 100, or two versions in an A/B test.
                        example:
                          - versionNumber: 4
                            weight: 100
                      updatedAt:
                        type: string
                        format: date-time
                        example: '2026-10-28T09:15:00.000Z'
                      servingVersionNumber:
                        type: integer
                        description: >-
                          The version with the larger share: the one the agent's
                          settings now show.
                        example: 4
                      weightsEnforced:
                        type: boolean
                        description: >-
                          Always `true`: calls are split by weight, and each
                          caller keeps getting the same version.
                        example: true
                      environmentRevisionId:
                        type: string
                        format: uuid
                        description: >-
                          The `prod` values revision in use when this was
                          written.
                        example: 1c5a7e93-4d2f-4b6a-9e8c-3f1d5b7a9c02
        '400':
          description: >-
            Invalid entries: weights don't add up to 100, more than two entries,
            a split weight outside 1-99, a repeated or unknown version, or a
            version using an expensive model with no LLM API key
            (`LLMApiKeyRequiredForExpensiveModel`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '401':
          description: 'Unauthorized: missing or invalid API key.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '403':
          description: >-
            Your API key or role does not have `agents:experiment`, or the
            change switches the serving version and you lack `agents:deploy`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '404':
          description: Voice agent not found in this project.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '409':
          description: >-
            The deployment changed since you last looked (`ReleaseStale`):
            `params.current` holds the current state. Or: Another request with
            the same `Idempotency-Key` is still running
            (`IdempotencyKeyInProgress`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '422':
          description: >-
            Deployments are off for this agent (`NotAllowedInState`, reason
            `VERSIONING_OFF`), a version is waiting for approval (reason
            `VERSION_PENDING`), or: The `Idempotency-Key` was already used with
            a different body (`IdempotencyKeyReused`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '500':
          description: Server Side Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    AgentVersionDeploymentEntry:
      type: object
      required:
        - versionNumber
        - weight
      properties:
        versionNumber:
          type: integer
          minimum: 1
          example: 4
        weight:
          type: integer
          minimum: 0
          maximum: 100
          description: Share of calls, in percent.
          example: 100
    AgentVersionError:
      type: object
      properties:
        code:
          type: integer
          description: Service error code (8400, 8403, 8404, 8409, ...).
          example: 8409
        message:
          type: string
          example: >-
            Your draft changed in another tab or through your API key. Reload it
            and try again.
        messageKey:
          type: string
          description: Stable error key.
          example: DraftStaleRevision
        params:
          type: object
          additionalProperties: true
          description: >-
            Details. `reason` names the case (for example `STALE_REVISION`,
            `NO_DRAFT`, `SESSION_ONLY`); `action` names a missing permission
            (for example `agents:deploy`).
          example:
            reason: STALE_REVISION
            revision: e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Pass the API key in the Authorization header, You need to put Token
        keyword before the API key. e.g. 'Authorization: Token <api-key>'

````

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