curl --request PUT \
--url https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/environments/{environmentId}/version \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"versionId": "a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"expectedVersionId": null
}
'{
"success": true,
"message": "success",
"data": {
"id": "5b9d1e7f-2c3a-4f8b-8d16-7e9f0a1b2c3d",
"name": "staging",
"isDefault": false,
"isLocked": true,
"revision": "f2a3b4c5-d6e7-4f8a-9b0c-1d2e3f4a5b6c",
"variables": [
{
"key": "api_host",
"value": "https://staging.example.com"
}
],
"savedBy": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Lina Haddad"
},
"updatedAt": "2026-10-28T09:14:02.000Z",
"publishedVersionId": "a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"deployedBy": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Lina Haddad"
},
"deployedAt": "2026-10-30T15:40:11.000Z"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8409,
"message": "This environment or the A/B split changed since you last looked. Review the current state and try again.",
"messageKey": "ReleaseStale",
"params": {
"reason": "STALE"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8409,
"message": "This environment or the A/B split changed since you last looked. Review the current state and try again.",
"messageKey": "ReleaseStale",
"params": {
"reason": "STALE"
}
}{
"code": 8409,
"message": "This environment or the A/B split changed since you last looked. Review the current state and try again.",
"messageKey": "ReleaseStale",
"params": {
"reason": "STALE"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}Deploy Version to Environment
Points one environment at a version: deploy, promote, switch or roll back. Needs deployments on for the agent. The permission depends on the environment: agents:publish for dev, agents:promote for staging, agents:deploy for prod. On prod the version gets 100% of calls, which ends any A/B test. Deploying an older version than the current one is recorded as a rollback. Send expectedVersionId (and for prod, expectedDeployment) to refuse the change if someone else deployed in the meantime.
curl --request PUT \
--url https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/environments/{environmentId}/version \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"versionId": "a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"expectedVersionId": null
}
'{
"success": true,
"message": "success",
"data": {
"id": "5b9d1e7f-2c3a-4f8b-8d16-7e9f0a1b2c3d",
"name": "staging",
"isDefault": false,
"isLocked": true,
"revision": "f2a3b4c5-d6e7-4f8a-9b0c-1d2e3f4a5b6c",
"variables": [
{
"key": "api_host",
"value": "https://staging.example.com"
}
],
"savedBy": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Lina Haddad"
},
"updatedAt": "2026-10-28T09:14:02.000Z",
"publishedVersionId": "a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"deployedBy": {
"id": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Lina Haddad"
},
"deployedAt": "2026-10-30T15:40:11.000Z"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8409,
"message": "This environment or the A/B split changed since you last looked. Review the current state and try again.",
"messageKey": "ReleaseStale",
"params": {
"reason": "STALE"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8409,
"message": "This environment or the A/B split changed since you last looked. Review the current state and try again.",
"messageKey": "ReleaseStale",
"params": {
"reason": "STALE"
}
}{
"code": 8409,
"message": "This environment or the A/B split changed since you last looked. Review the current state and try again.",
"messageKey": "ReleaseStale",
"params": {
"reason": "STALE"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}Authorizations
Headers
Optional. Send a unique value to retry safely: a retry with the same key within 10 minutes returns the first response instead of applying the change again. Reusing a key with a different body is refused (422 IdempotencyKeyReused); a retry while the first request is still running gets 409 IdempotencyKeyInProgress.
255"b3f1c2d4-save-1"
Path Parameters
Body
Was this page helpful?