لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/source-storage/save.md فهرس التوثيق — /llms.txt

مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.

Save a snapshot

POST /v1/apps/:id/sources

Explicitly saves a source archive. Use it when you need to tag a version, record an intermediate result without deploying, or prepare a rollback.

When you deploy, a snapshot is created automatically.

Parameters

Parameter Type Required Description
Parameterid (path) Typestring Requiredyes DescriptionApplication identifier. Get it via GET /v1/apps.
ParameterContent-Type (header) Typestring Requiredyes DescriptionArchive format. Allowed values: application/gzip, application/x-tar, application/zip, application/octet-stream. Any other value → 400 INVALID_CONTENT_TYPE. The declared format is checked against the first bytes of the archive: a direct contradiction (application/gzip declared for zip bytes, or the other way round) → 415 UNSUPPORTED_ARCHIVE_FORMAT.
ParameterContent-Length (header) Typenumber Requiredyes DescriptionBody size in bytes. An upload without it (Transfer-Encoding: chunked) is not accepted → 411 MISSING_CONTENT_LENGTH.
ParameterX-Filename (header) Typestring Requiredno DescriptionAn arbitrary display filename, for example app-v1.tar.gz. If it is not provided, the name is derived from Content-Type, which gives source.tar.gz for application/gzip. Characters outside the a-zA-Z0-9._- set → 400 INVALID_FILENAME.
ParameterX-Tags (header) Typestring Requiredno DescriptionComma-separated tags; spaces around commas are dropped. A tag may contain only Latin letters, digits, _, and -; any other character → 400 INVALID_TAGS. manual and published protect the version from automatic cleanup; any other tags are free-form labels.
ParameterX-Note (header) Typestring Requiredno DescriptionAn arbitrary note that is saved in the version record. fetch in JavaScript accepts only Latin-1 characters in headers: Cyrillic text in X-Note throws a TypeError before the request is sent.
ParameterX-AI-Session-Id (header) Typestring Requiredno DescriptionAI session identifier. Groups snapshots in the manifest by session.

Request fields (body)

The body is raw archive bytes, not multipart/form-data. The maximum size is 500 MB.

The body is accepted as a stream, so its length has to be declared up front: the request must carry Content-Length. A chunked upload (Transfer-Encoding: chunked, no length) is rejected with 411 MISSING_CONTENT_LENGTH — the platform will not buffer the archive in memory to measure it for the client. A declared length above the cap is rejected with 413 before the body is read.

curl sets the length automatically with --data-binary @app.tar.gz and when reading from standard input with --data-binary @-.

Examples

The JavaScript examples run in Node.js: save the code in an .mjs file. Replace <APP_ID> with your application ID and place app-sources.tar.gz in the same directory as the example file.

curl — personal key

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/apps/<APP_ID>/sources \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/gzip" \
  -H "X-Note: OAuth sign-in" \
  -H "X-Tags: manual" \
  --data-binary @app-sources.tar.gz

curl — OAuth application

Terminal
curl -X POST https://vibecode.bitrix24.com/v1/apps/<APP_ID>/sources \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/gzip" \
  -H "X-Note: OAuth sign-in" \
  -H "X-Tags: manual" \
  --data-binary @app-sources.tar.gz

JavaScript — personal key

javascript
import { readFile } from 'node:fs/promises'

const appId = '<APP_ID>'
const archive = await readFile(new URL('./app-sources.tar.gz', import.meta.url))

const res = await fetch(
  `https://vibecode.bitrix24.com/v1/apps/${appId}/sources`,
  {
    method: 'POST',
    headers: {
      'X-Api-Key': 'YOUR_API_KEY',
      'Content-Type': 'application/gzip',
      'X-Note': 'OAuth sign-in',
      'X-Tags': 'manual',
    },
    body: archive,
  },
)
const json = await res.json()
console.log(json.data.versionId, 'deduplicated:', json.data.deduplicated)

JavaScript — OAuth application

javascript
import { readFile } from 'node:fs/promises'

const appId = '<APP_ID>'
const archive = await readFile(new URL('./app-sources.tar.gz', import.meta.url))

const res = await fetch(
  `https://vibecode.bitrix24.com/v1/apps/${appId}/sources`,
  {
    method: 'POST',
    headers: {
      'X-Api-Key': 'YOUR_APP_KEY',
      'Authorization': 'Bearer USER_SESSION_TOKEN',
      'Content-Type': 'application/gzip',
      'X-Note': 'OAuth sign-in',
      'X-Tags': 'manual',
    },
    body: archive,
  },
)
const json = await res.json()
console.log(json.data.versionId, 'deduplicated:', json.data.deduplicated)

For a zip archive, only one value changes in the same examples: Content-Type: application/zip, and the body is the bytes of the zip file.

Response fields

Field Type Description
Fieldsuccess Typeboolean Descriptiontrue for a successful response, including when saving is skipped.
Fielddata Typeobject DescriptionSave result: the version fields, or skipped and reason if saving is disabled.
Fielddata.versionId Typestring DescriptionVersion identifier of the form v<N>.
Fielddata.id Typestring DescriptionInternal identifier of the snapshot record. Returned only in the save response: the version list and the single-version metadata do not carry this field.
Fielddata.filename Typestring DescriptionName of the archive file in storage.
Fielddata.contentType Typestring DescriptionArchive type: application/gzip, application/zip, application/x-tar, or application/octet-stream.
Fielddata.sha256 Typestring DescriptionSHA-256 of the archive contents. Used for deduplication of archives saved for the same owner.
Fielddata.size Typenumber DescriptionArchive size in bytes.
Fielddata.timestamp Typestring DescriptionSave time (ISO 8601, UTC).
Fielddata.tags Typestring[] DescriptionVersion tags. manual and published protect the version from automatic cleanup; any other tags are free-form labels from X-Tags. If the archive was already saved (deduplicated: true), the tags from the request are added to the existing version's tags.
Fielddata.note Typestring | null DescriptionNote from the X-Note header or null. When the same archive is saved again, a note provided in the request replaces the previous note.
Fielddata.deduplicated Typeboolean Descriptiontrue if an archive with the same contents was already saved for this owner — the existing version is returned.
Fielddata.skipped Typeboolean DescriptionReturned instead of the version fields when saving is disabled. Always true.
Fielddata.reason Typestring DescriptionWhy the save was skipped: DISABLED_GLOBALLY or DISABLED_FOR_PORTAL. Returned together with skipped.

Response example

HTTP 201 — the snapshot was saved. Saving the same archive again also returns 201, with data.deduplicated set to true:

JSON
{
  "success": true,
  "data": {
    "versionId": "v3",
    "id": "cmuye5vkc0kd74bou8q1fnreo",
    "filename": "2026-10-07T17-38-38-988Z-v3-manual.tar.gz",
    "contentType": "application/gzip",
    "sha256": "4cd663d7b491eb3dcbe46f433a3822077410873e302737ce093c84c7a915af08",
    "size": 159,
    "timestamp": "2026-10-07T17:38:38.988Z",
    "tags": ["manual"],
    "note": "OAuth sign-in",
    "deduplicated": false
  }
}

HTTP 200 — saving is disabled, no snapshot created:

JSON
{
  "success": true,
  "data": {
    "skipped": true,
    "reason": "DISABLED_GLOBALLY"
  }
}

reason — "DISABLED_GLOBALLY" (the platform has not enabled the feature) or "DISABLED_FOR_PORTAL" (the Bitrix24 account owner disabled it for their account). In either case POST /v1/apps/:id/publish does not check for a snapshot.

Error response example

400 — Content-Type is not in the list of allowed archive formats:

JSON
{
  "success": false,
  "error": {
    "code": "INVALID_CONTENT_TYPE",
    "message": "Content-Type \"text/plain\" not allowed. Allowed: application/gzip, application/x-tar, application/zip, application/octet-stream",
    "hint": {
      "method": "binary (not multipart)",
      "acceptedContentTypes": [
        "application/gzip",
        "application/x-tar",
        "application/zip",
        "application/octet-stream"
      ],
      "mcpToolName": "save_sources",
      "docsUrl": "/docs/source-storage"
    }
  }
}

The main hint fields are shown. The full response also carries explanation with a breakdown of the format, metadataHeaders with the list of metadata headers, and exampleCurl with a ready-made command.

Errors

HTTP Code Description
HTTP400 CodeINVALID_CONTENT_TYPE DescriptionContent-Type is not in the list of allowed archive formats. multipart/form-data is not accepted — send the raw archive bytes.
HTTP400 CodeINVALID_BLOB DescriptionThe request body is not a binary buffer — for example, text was passed.
HTTP400 CodeINVALID_FILENAME DescriptionThe X-Filename header contains characters outside the a-zA-Z0-9._- set.
HTTP400 CodeINVALID_TAGS DescriptionA tag from the X-Tags header contains invalid characters (a-zA-Z0-9_- are allowed).
HTTP400 CodeSTORAGE_UPLOAD_LENGTH_MISMATCH DescriptionThe declared Content-Length did not match the actual body size. The check happens at the end of the stream, so the error is returned after the bytes have been sent. Recompute the length and retry.
HTTP402 CodeBILLING_INSUFFICIENT DescriptionInsufficient balance — storage writes are paused. Top up the balance and retry.
HTTP507 CodeSTORAGE_QUOTA_EXCEEDED DescriptionThe snapshot does not fit into the portal's remaining storage cap. The cap is optional: it is switched on by the platform and applies only to portals that have no commercial Bitrix24 plan and never had one. Usage is counted across the whole portal, not per application.
HTTP403 CodeSOURCE_APP_ID_MISMATCH DescriptionThe call was made with an authorization key vibe_app_… issued for a different application. Such a key can access only its own application's snapshots, even when both applications were created by the same author.
HTTP403 CodeNOT_AUTHORIZED DescriptionOnly the application author, the application OAuth key, or a portal administrator can manage snapshots.
HTTP403 CodeINFRA_FORBIDDEN_FOR_COWORK_KEY DescriptionThe call was made with a Cowork/Code key — such a key works with data only and cannot perform write operations. To issue a key that can, see Project key for deploy.
HTTP404 CodeAPP_NOT_FOUND DescriptionThe application does not exist, was deleted, or belongs to another portal.
HTTP411 CodeMISSING_CONTENT_LENGTH DescriptionThe request arrived without Content-Length (a chunked upload). Declare the body length and retry.
HTTP413 Code— DescriptionThe archive size exceeds the 500 MB limit.
HTTP415 CodeUNSUPPORTED_ARCHIVE_FORMAT DescriptionThe first bytes of the archive directly contradict the declared Content-Type: application/gzip was declared while a zip was sent, or the other way round. The response body carries error.hint.declared and error.hint.detected. The types application/x-tar and application/octet-stream never trigger this refusal — their signatures are not checked in the first bytes.
HTTP500 CodeSOURCE_STORAGE_ERROR DescriptionInternal storage error.
HTTP503 CodeSTORAGE_STS_UNAVAILABLE DescriptionStorage is temporarily unavailable (a failure to issue temporary access credentials) — retry the request.

Full list of common API errors — Errors.

Known specifics

Deduplication is scoped to a single owner. Matching happens only among the versions of the same application for POST /v1/apps/:id/sources and the same server for POST /v1/infra/servers/:id/sources. The very same archive saved on two different servers or under two applications yields two versions and two objects in storage — each owner keeps its own version history.

The entire archive is sent again on a repeat save. The platform computes sha256 as it receives the data and can identify a match only after receiving the entire request body.

A deduplicated save clears 409 SNAPSHOT_REQUIRED. The check before POST /v1/apps/:id/publish treats a deduplicated save like a new save: it records when the version was submitted again and measures the snapshot's age from that time. The data.timestamp field still reports when the version was created — it does not move, so the stored file name and the version's place in the retention policy stay the same. If you re-save the very same sources after a 409 SNAPSHOT_REQUIRED, the next publish goes through — you do not have to change the bytes to refresh the snapshot.

See also