For AI agents: markdown of this page — /docs-content-en/applications/replace-server.md documentation index — /llms.txt

Replace an application server

POST /v1/applications/:id/replace-server

Moves the application to another server: an existing server of the owner, or a new one that the method creates itself. The old server is not deleted. The application is unlinked from it, and the server stays with its owner. Before calling, find out whether a replacement is possible and choose the server through GET /v1/applications/:id/available-servers.

Only the card owner can call this method, and only with their own keys. An administrator of the Bitrix24 account who does not own the application replaces the server in their Vibecode account.

Authorization: X-Api-Key with the vibe:infra scope.

Parameters

Parameter Type Required Description
Parameterid (path) Typestring Requiredyes DescriptionApplication ID. List: GET /v1/applications
ParameterIdempotency-Key (header) Typestring Requiredno Descriptionnew form only, ignored on { serverId }. 1 to 255 characters from A-Z, a-z, 0-9, _, ., :, -; surrounding spaces are trimmed. The key is scoped to the calling API key. How a retry works is described under "Known behaviors"

Request fields (body)

The body takes one of two forms. Fields of the two forms cannot be mixed, and extra fields return 400 VALIDATION_ERROR.

Your own existing server.

Field Type Required Description
FieldserverId Typestring Requiredyes DescriptionServer ID from servers[].id of GET /v1/applications/:id/available-servers

A new server.

Field Type Required Description
Fieldprovider Typestring Requiredyes DescriptionProvider ID, as in POST /v1/infra/servers
Fieldplan Typestring Requiredyes DescriptionProvider plan ID, as in POST /v1/infra/servers
Fieldregion Typestring Requiredno DescriptionProvider region ID

Examples

curl — personal key

Terminal
curl -X POST \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"serverId": "srv_new"}' \
  https://vibecode.bitrix24.com/v1/applications/cmsw806qi0000tdskiw2aegii/replace-server

curl — OAuth application

Terminal
curl -X POST \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"serverId": "srv_new"}' \
  https://vibecode.bitrix24.com/v1/applications/cmsw806qi0000tdskiw2aegii/replace-server

JavaScript — personal key

javascript
const id = 'cmsw806qi0000tdskiw2aegii'
const res = await fetch(`https://vibecode.bitrix24.com/v1/applications/${id}/replace-server`, {
  method: 'POST',
  headers: { 'X-Api-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
  body: JSON.stringify({ serverId: 'srv_new' }),
})
const { data } = await res.json()

for (const warning of data.warnings) {
  console.warn('Needs manual follow-up:', warning)
}

JavaScript — OAuth application

javascript
const id = 'cmsw806qi0000tdskiw2aegii'
const res = await fetch(`https://vibecode.bitrix24.com/v1/applications/${id}/replace-server`, {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ serverId: 'srv_new' }),
})
const { data } = await res.json()

A new server is created with the body {"provider": "bitrix-cloud", "plan": "bc-small", "region": "bc-eu-central"}. This call is paid. To keep a retry from creating a second server, send the Idempotency-Key header, see "Known behaviors".

Response fields

Field Type Description
Fieldsuccess Typeboolean DescriptionAlways true on success
Fielddata.serverId Typestring DescriptionID of the server the application now points to
Fielddata.oldServerId Typestring | null DescriptionID of the previous server. null if the application had no server
Fielddata.branch Typestring Descriptionexisting — moved to your own server, new — a new server was created
Fielddata.appUrlMoved Typeboolean DescriptionWhether the application address was moved to the new server
Fielddata.warnings Typearray DescriptionWhat could not be completed after the move. An empty array if everything went through. Values are in the table below
Fielddata.callerKeyManagesServer Typeboolean | null DescriptionWhether the key that made the call manages the new server. null if the platform could not read it back

Values of data.warnings:

Value What happened and what to do
ValueKEY_ASSIGN_FAILED What happened and what to doThe new server could not be handed to the application key. The application points to the new server, but no key was assigned to manage it
ValueAPP_URL_MOVE_FAILED What happened and what to doThe application address was not moved to the new server. Move it manually
ValueAPP_URL_MANUAL What happened and what to doThe application has a custom address and the platform kept it as is
ValueCATALOG_STALE What happened and what to doThe old server had a published catalog card. Publish the card again
ValueSERVER_KEY_STALE What happened and what to doThe chosen existing server keeps an application key in its environment that was revoked or has expired. Update the key in the server environment

Response example

JSON
{
  "success": true,
  "data": {
    "serverId": "srv_new",
    "oldServerId": "srv_old",
    "branch": "existing",
    "appUrlMoved": true,
    "warnings": [],
    "callerKeyManagesServer": true
  }
}

Error response example

409 — the server is already linked to another application:

JSON
{
  "success": false,
  "error": {
    "code": "SERVER_ALREADY_LINKED",
    "message": "Server is linked to another application"
  }
}

Errors

HTTP Code Description
HTTP400 CodeVALIDATION_ERROR DescriptionThe body matches neither { serverId } nor { provider, plan, region? }, or has extra fields
HTTP400 CodeINVALID_IDEMPOTENCY_KEY Descriptionnew form only: the Idempotency-Key header is empty, longer than 255 characters or contains disallowed characters
HTTP400 CodeSERVER_ALREADY_CURRENT DescriptionThe server is already linked to this application
HTTP400 CodeINVALID_PLAN Descriptionnew form only: the plan in plan is not in the provider catalog
HTTP400 CodeINVALID_REGION Descriptionnew form only: the region in region is not in the provider catalog
HTTP400 CodePROVIDER_DEPRECATED Descriptionnew form only: the provider is retired
HTTP400 CodeKEY_NOT_ELIGIBLE Descriptionnew form only: the key can no longer own a server
HTTP401 CodeNO_PORTAL DescriptionThe key is not bound to a portal
HTTP401 CodeMISSING_API_KEY DescriptionThe X-Api-Key header is missing
HTTP401 CodeINVALID_API_KEY DescriptionThe key is not recognized: no such key exists on the platform
HTTP402 CodeACCOUNT_FROZEN DescriptionThe portal balance is frozen. If only paid calls are closed, moving to your own existing server works, and the new form gets this refusal with userMessage and alternatives
HTTP402 CodeCOMMERCIAL_PLAN_REQUIRED Descriptionnew form only: the platform did not find the record of the portal the key is bound to and cannot check access
HTTP402 CodeTRIAL_PORTAL_LIMIT Descriptionnew form only: the server quota of the portal on trial access is used up
HTTP402 CodePLAN_NOT_ALLOWED_ON_TRIAL Descriptionnew form only: the plan in plan is not available on the trial. Allowed plans are in error.details.allowedPlans
HTTP402 CodeINT_TARIFF_REQUIRED Descriptionnew form only: the account gets access through its Bitrix24 plan, and a commercial plan is required
HTTP402 CodeINT_VIBE_PLUS_REQUIRED Descriptionnew form only: the Bitrix24 account needs a Vibe+ plan
HTTP402 CodeSELFHOSTED_NOT_AVAILABLE Descriptionnew form only: on-premise Bitrix24 is not yet available on this installation. Buying a plan does not lift the refusal
HTTP403 CodeINFRA_SCOPE_REQUIRED DescriptionThe key lacks the vibe:infra scope
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key is read-only
HTTP403 CodeINFRA_FORBIDDEN_FOR_COWORK_KEY DescriptionA key with the vibe:cowork scope works with data only
HTTP403 CodeFORBIDDEN DescriptionThe application does not belong to the key owner
HTTP403 CodeMANAGEMENT_KEY_NO_ENTITY_ACCESS DescriptionManagement key: use a personal key or an authorization key
HTTP403 CodePORTAL_KEY_REQUIRED DescriptionThe key record is damaged and has no owner
HTTP403 CodeINFRA_NOT_PERMITTED Descriptionnew form only: infrastructure is turned off on the platform or for the portal
HTTP403 CodeSERVER_CREATION_DISABLED Descriptionnew form only: the portal policy forbids creating servers
HTTP403 CodeSERVER_CREATION_ADMINS_ONLY Descriptionnew form only: the portal policy lets only administrators create servers
HTTP403 CodeVIBE_DEMO_EXPIRED Descriptionnew form only: the Vibe+ plan or trial has ended
HTTP404 CodeAPPLICATION_NOT_FOUND DescriptionNo such application on the portal the key is bound to
HTTP404 CodeSERVER_NOT_FOUND DescriptionThe server does not exist, belongs to someone else, or cannot be linked to an application: an agent server, a bot server or a galaxy host
HTTP404 CodePROVIDER_NOT_FOUND Descriptionnew form only: the provider is unknown or closed for this portal
HTTP409 CodeIDEMPOTENCY_KEY_ALREADY_USED Descriptionnew form only: the Idempotency-Key was already used with another application or body, the application has since moved to another server, or the outcome of the previous call is unknown
HTTP409 CodeIDEMPOTENCY_CONCURRENT_RETRY Descriptionnew form only: a concurrent request reserved the same Idempotency-Key
HTTP409 CodeSERVER_ALREADY_LINKED DescriptionThe server is linked to another application
HTTP409 CodeAPPLICATION_OP_IN_PROGRESS DescriptionAnother operation is changing the application's server link, or the link changed during the request. Retry shortly
HTTP409 CodeREISSUE_IN_PROGRESS DescriptionThe application key or its server link is busy with a key reissue, secret delivery or deletion. Retry shortly
HTTP409 CodeAPPLICATION_KEY_RECOVERY_REQUIRED DescriptionAn unfinished key replacement blocks the move. Finish or recover it first
HTTP409 CodePORTAL_ORIGIN_CUTOVER_BUSY DescriptionThe portal address is being changed by another operation, retry shortly
HTTP429 CodeRATE_LIMITED Description10 requests per minute for the card owner, whichever key they call with
HTTP429 CodeSERVER_LIMIT Descriptionnew form only: the per-key server limit is reached
HTTP429 CodeUSER_SERVER_LIMIT Descriptionnew form only: the per-user server limit is reached
HTTP502 CodeAPPLICATION_SERVER_ATTACH_FAILED DescriptionThe new server was created but could not be linked. The server was removed and the application stays on the old one
HTTP502 CodePROVIDER_ERROR Descriptionnew form only: the call to the cloud provider failed. The response carries error.incidentCode, quote it to support
HTTP502 CodePROVIDER_NOT_CONFIGURED Descriptionnew form only: the provider is not configured on the platform — it has no credentials or no price for the chosen plan. The response carries error.incidentCode
HTTP503 CodePORTAL_ORIGIN_CUTOVER_UNAVAILABLE DescriptionThe portal address guard is unavailable, retry later

The error.message text is in English and meant for logs: build interface texts from error.code. The full list of common API errors is in Errors.

Known behaviors

  • A failure after the link is written does not become an error. Once the application points to the new server, the method answers 200 and lists what could not be completed in warnings. An error response happens only for what went wrong before the link was written. A client that looks at the response status alone will miss the warnings: always read warnings.
  • Retrying the new form with Idempotency-Key. A retry with the same key and the same body within 24 hours of the first call creates no second server. If the replacement completed, the 200 response repeats the original data.serverId, data.oldServerId and data.appUrlMoved with an empty data.warnings and carries the Idempotent-Replayed: true header. If the outcome is unknown or the application has already moved to another server, the answer is 409 IDEMPOTENCY_KEY_ALREADY_USED. Then read GET /v1/applications/:id, where server.id is the application's current server, and check your Vibecode account for an unlinked server before buying again. After 24 hours the duplicate protection may expire. Without the header, a retry may create a second server.
  • The key of the call is not reassigned. The managing key of the new server is the application's own key: the authorization key if it has one, otherwise the personal key. The key you called with stays as it was. callerKeyManagesServer tells whether it manages the new server. It is false when the application has an authorization key or the target server is a galaxy container.
  • The server is created for the card owner. Limits and payment conditions apply to the owner, not to the administrator of the Bitrix24 account.
  • The old server stays. It is unlinked from the application and keeps running for the owner. If you do not need it, delete it separately with DELETE /v1/infra/servers/:id.
  • Whether to show the button is decided by available-servers. It also names the reason for a refusal of the new form in advance. All other reasons arrive as error codes from the table above.

See also