POST /teams/{teamId}/files/{fileId}/replace/init
Reservar nova versão de um arquivo existente (passo 1/3)
- Access: Signed in
- Service:
https://files-api.axuz.net
Accepted authentication
sessionCookie— Sessão plena Axuz (cookie de sessão da casa). Sessão restrita é 403 enrollment_required.bearerSession— JWT de acesso da sessão em `Authorization: Bearer`.
Re-upload de arquivo já existente. ABAC: só o uploaded_by do arquivo OU um admin/owner do team (IsTeamAdmin) — mesma regra do delete. Valida content_type contra a allowlist e size_bytes contra o teto do serviço, então insere uma row pending em files_file_versions.
upload_url é o presigned PUT do bucket (S3/R2) ou o path proxy /teams/{teamId}/files/{fileId}/replace/upload/{versionId} quando o backend é local/Bunny; ?proxy=1 força o proxy.
name é opcional — ausente, herda o nome da versão corrente (permite renomear no mesmo passo do replace).
Fonte: internal/drive/handler_replace.go:34.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
teamId | path | string | yes | |
fileId | path | string | yes | |
proxy | query | string | no |
Request body
application/json · Required
| Name | Type | Required | Description |
|---|---|---|---|
name | string | no | Opcional — ausente/vazio herda o nome da versão corrente. |
content_type | string | yes | |
size_bytes | integer | yes |
{
"name": "string",
"content_type": "string",
"size_bytes": 1
}Responses
201
Versão pending reservada
| Name | Type | Required | Description |
|---|---|---|---|
version | FilesFileVersion | no | Row de |
version.id | string | no | |
version.file_id | string<uuid> | no | |
version.version | integer | no | |
version.storage_key | string | no | |
version.name | string | no | |
version.content_type | string | no | |
version.size_bytes | integer | no | |
version.sha256 | string | null | no | |
version.status | string | no | enum: |
version.uploaded_by | string<uuid> | no | |
version.uploaded_at | string<date-time> | no | |
version.completed_at | string<date-time> | null | no | |
version.is_current | boolean | no | |
upload_url | string | no | Presigned PUT do bucket, ou o path relativo |
400
Payload/params inválidos
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes | Chave/slug do erro |
message | string | no |
401
Sem credencial valida
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
403
Não é o uploader do arquivo nem admin/owner do team
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes | Chave/slug do erro |
message | string | no |
404
Recurso ausente
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes | Chave/slug do erro |
message | string | no |
413
Arquivo acima do tamanho máximo configurado
429
Limite de requisições excedido.
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
500
Erro interno. Tente de novo com backoff; reporte o X-Request-Id.
| Name | Type | Required | Description |
|---|---|---|---|
error | string | yes |
Examples
"Try it" is turned off in this reference. Use the examples with your test credential.
curl
curl -sS -X POST 'https://files-api.axuz.net/teams/TEAM_ID/files/FILE_ID/replace/init' \
-H "Authorization: Bearer $AXUZ_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"string","content_type":"string","size_bytes":1}'Node.js
const res = await fetch("https://files-api.axuz.net/teams/TEAM_ID/files/FILE_ID/replace/init", {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.AXUZ_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "string",
"content_type": "string",
"size_bytes": 1
}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
console.log(await res.json());Python
import os
import requests
res = requests.request(
"POST",
"https://files-api.axuz.net/teams/TEAM_ID/files/FILE_ID/replace/init",
headers={
"Authorization": f"Bearer {os.environ['AXUZ_TOKEN']}",
},
json={
"name": "string",
"content_type": "string",
"size_bytes": 1,
},
timeout=30,
)
res.raise_for_status()
print(res.json())