CropPath 开发者

API 参考

sandbox

1 个操作

POST /v1/sandbox/accounts

Create a sandbox account (hosted sandbox only)

无需身份验证 · createSandboxAccount

The hosted sandbox only (#218, x-sandbox-only): on every other deployment, CropPath's live service included, this path answers 404 no_such_route for every method, exactly like an unknown path, and creates nothing.

Anonymous: no session and no token. Creates a fresh company of its own (tenant_id, sbx- and 16 random characters) and returns, once, an API token for it (api_token, agt_...): role tenant_admin of that company only, valid 24 hours (expires_at, Unix seconds). Send it as Authorization: Bearer to base_url (the sandbox's address); it never reaches another company (404, like a missing record) or a platform operation (403). Within a few minutes the company holds the demo scenario: a packing house, a growing area and its grower, devices, a lot of 128 measured fruits with its lab results, packing, seal and shipment, as on the man1 and man2 mockups. The company and all its data are deleted 7 days after its creation (the sandbox's setting); no email is ever sent; webhooks refuse private and loopback addresses as everywhere.

Limits: a client address creates at most 5 companies an hour (the sandbox's setting; the address is the CF-Connecting-IP a trusted proxy sends, else the socket peer), then 429 with Retry-After before anything is done; and the sandbox holds at most 500 live companies (its setting), then 503 sandbox_full. The body is empty or {}. Audited (sandbox.account.create, actor system:sandbox, in the creation's transaction: the company and the token's expiry, never the token). Every answer is no-store.

请求体

SandboxAccountCreate (可选)

媒体类型: application/json

请求示例 · application/json
{}

响应

状态码类型说明
201SandboxAccount
application/json

The new company and its API token, shown this once.

400Error
application/json

A body that is not empty or {} (invalid JSON, not an object, or any field), or a bad X-Request-Id. Nothing is created.

404Error
application/json

Not the hosted sandbox: on every other deployment the path does not exist (no_such_route, for every method).

405Error
application/json

The path exists but not for this method. Allow lists the methods it accepts.

413Error
application/json

The request body is over 1 MiB.

429Error
application/json

Too many sandbox accounts from this client address (5 an hour unless the sandbox sets another limit). Nothing was done, and no audit row is written; retry after Retry-After seconds.

500Error
application/json

Unexpected failure; the detail is only in the server log.

503Error
application/json

The sandbox holds as many live companies as it may (500 unless it sets another cap): nothing is created; retry later. Companies are deleted 7 days after their creation, which frees places.

响应头

名称状态码类型说明
X-Request-Id201string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control201string

no-store.

X-Request-Id400string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control400string

no-store.

X-Request-Id404string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id405string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Allow405string

Comma-separated methods the path accepts.

X-Request-Id413string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id429string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control429string

no-store.

Retry-After429string

Seconds to wait before retrying.

X-Request-Id500string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

X-Request-Id503string

Request id: the caller's X-Request-Id when it is 1 to 64 of A-Z a-z 0-9 . _ -, otherwise a generated one.

Cache-Control503string

no-store.

Retry-After503string

Seconds to wait before retrying.

响应示例

响应 201 · application/json
{
  "tenant_id": "sbx-k3m7q2xw5zr4tn6p",
  "api_token": "agt_Q2hhbmdlIG1lIG5vdzogdGhpcyBpcyBhbiBleGFtcGx",
  "expires_at": 1790086400.5,
  "base_url": "https://sandbox-txng.theio.vn"
}
响应 400 · application/json · invalid_json
{
  "error": "invalid JSON",
  "code": "invalid_json"
}
响应 400 · application/json · not_an_object
{
  "error": "expected a JSON object",
  "code": "expected_a_json_object"
}
响应 400 · application/json · unknown
{
  "error": "unknown fields: tenant_id",
  "code": "unknown_fields"
}
响应 400 · application/json · bad_request_id
{
  "error": "bad request id",
  "code": "bad_request_id"
}
响应 404 · application/json
{
  "error": "no such route",
  "code": "no_such_route"
}
响应 405 · application/json
{
  "error": "method not allowed",
  "code": "method_not_allowed"
}
响应 413 · application/json
{
  "error": "body too large",
  "code": "body_too_large"
}
响应 429 · application/json
{
  "error": "too many requests",
  "code": "too_many_requests"
}
响应 500 · application/json
{
  "error": "internal error",
  "code": "internal_error"
}
响应 503 · application/json
{
  "error": "sandbox full: the sandbox holds as many companies as it may; try again later",
  "code": "sandbox_full"
}