Create sites with OAuth
POST /v1/team/sites creates a site in the company of the person who connected the app. It is the only aggregate /v1/team* route that accepts an OAuth bearer; the others answer 403 for it.
Requirements
Section titled “Requirements”| Requirement | Detail |
|---|---|
| Scope | sites:create, literal. No package contains it. High risk in the catalog, only for group apps (see Scopes) |
| Company owner | The grant’s person must be the owner of the company at the time of the call. Otherwise: 403 insufficient_scope, message only the company owner may do this. The check uses a cache of up to 30 s; if it cannot be made, 503 unavailable |
| Grant not restricted to sites | A grant restricted to named sites gets 403 RESTRICTED_KEY_CANNOT_CREATE_SITES (this team key is restricted to named sites and cannot create sites). A whole-company grant works |
Idempotency-Key |
Required, text of up to 255 bytes. Missing or empty: 400 IDEMPOTENCY_KEY_REQUIRED; above 255 bytes: 400 IDEMPOTENCY_KEY_TOO_LONG |
Request
Section titled “Request”The body is JSON of up to 16 KiB (above that, 413 payload_too_large). Only these fields are accepted; any other is dropped.
| Field | Required | Note |
|---|---|---|
slug |
yes | Site identifier |
name |
no | Name |
primary_domain |
no | Primary domain |
theme_id |
no | Theme |
default_language |
no | Default language |
multi_lang_enabled |
no | Boolean |
enabled_languages |
no | List of languages |
curl -s -X POST https://api.canverly.net/v1/team/sites \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{"slug":"my-new-site","name":"My new site","default_language":"pt-BR"}'201 response
Section titled “201 response”{ "id": "...", "id_ulid": "...", "slug": "my-new-site", "name": "My new site", "status": "...", "primary_domain": "...", "default_language": "pt-BR", "enabled_languages": ["pt-BR"], "created_at": "..."}Repeating the request with the same Idempotency-Key returns the original result and does not spend the limit.
Limit: 5 successful creations per grant
Section titled “Limit: 5 successful creations per grant”The limit is per grant (the connection), not per person, app or company. When exceeded, the response is:
HTTP/1.1 429 Too Many RequestsRetry-After: 3600{"error":{"code":"SITES_CREATE_DAILY_LIMIT","message":"at most 5 sites may be created per day by this connection; retry after the time in Retry-After"}}Retry-After is in seconds (minimum 1; 3600 when the limiter does not report one). Use it.
Counting rules:
- Only a successful creation spends. An idempotent replay, a scope refusal, an invalid body and a creation failure (licensing 503, 409, etc.) do not. The limit is probed before creating, without spending; the charge of 1 unit comes after success.
- A company
ck_key does not go through this ceiling; it applies only to acvt_bearer. - If the limiter (Redis) is down, the route fails closed with 503
unavailable. sites:createcounts as a write in the grant’s general quota (60 per minute) and in the app bucket (6000 per minute), before its own ceiling.
Errors
Section titled “Errors”| Status | error.code |
When |
|---|---|---|
| 400 | INVALID_SLUG |
Invalid slug (relayed from the sites service) |
| 400 | IDEMPOTENCY_KEY_REQUIRED |
Idempotency-Key missing or empty |
| 400 | IDEMPOTENCY_KEY_TOO_LONG |
Idempotency-Key above 255 bytes |
| 400 | Invalid body | |
| 401 | UNAUTHENTICATED |
No credential or an invalid ck_ key (an invalid OAuth bearer answers invalid_token) |
| 403 | insufficient_scope |
No sites:create scope, or the person is not the owner |
| 403 | RESTRICTED_KEY_CANNOT_CREATE_SITES |
Grant restricted to named sites |
| 409 | SLUG_TAKEN |
The slug already exists |
| 409 | SITE_LIMIT_REACHED |
The company plan holds no more sites |
| 413 | payload_too_large |
Body above 16 KiB |
| 429 | SITES_CREATE_DAILY_LIMIT |
The grant’s ceiling (above) |
| 503 | LICENSING_UNAVAILABLE |
Site licensing is unavailable; retryable |
| 503 | unavailable |
Limiter down, owner check indeterminate or internal credential refused |
| 502 | upstream |
Another error from the sites service, with no echo of the detail |
Every 5xx goes out with message: "internal error"; decide by the code, not the message. The licensing 503 does not spend the limit and can be retried with the same Idempotency-Key.
Creation records site.create with the grant’s actor (oauth_app). On this route scope_used is not annotated (that annotation belongs to the middleware of the /v1/sites/{site}/... routes).
The served OpenAPI describes POST /v1/team/sites by bearer and the SITES_CREATE_DAILY_LIMIT 429. Only success spends the limit; a licensing failure does not.
See also: API v2, Sites, Limits and errors.