Create a space
Create a new space for the organization. Spaces scope end-users and their sessions.
POST
/api/spacesbetter-auth.session_token<token>
Cookie session from Better Auth. Requires X-Org-Id header for org-scoped routes.
In: cookie
Header Parameters
X-Org-Id?string
Organization ID. Required for cookie auth. Not needed for API key auth (org resolved from key).
Format
uuidRequest Body
application/json
curl -X POST "https://your-instance/api/spaces" \ -H "Content-Type: application/json" \ -d '{ "name": "string" }'{
"id": "spc_5b8c0e13-4f7a-4d92-b3c6-71e0a4d9f582",
"object": "space",
"orgId": "550e8400-e29b-41d4-a716-446655440000",
"name": "My SaaS App",
"isDefault": false,
"settings": {
"allowedRedirectDomains": [
"myapp.com",
"staging.myapp.com"
]
},
"visibility": "open",
"default_role": "operator",
"personal": false,
"access": "member",
"role": {
"kind": "preset",
"key": "admin",
"name": "admin"
},
"permissions": [
"agents:read",
"agents:run"
],
"created_by": "usr_k7x9m2p4q1",
"createdAt": "2026-01-15T10:30:00Z",
"updatedAt": "2026-01-15T10:30:00Z"
}{
"type": "https://docs.appstrate.dev/errors/validation-failed",
"title": "Validation Failed",
"status": 400,
"detail": "name: Invalid input: expected string, received undefined (+2 more)",
"code": "validation_failed",
"request_id": "req_abc123",
"errors": [
{
"field": "name",
"code": "required",
"message": "Invalid input: expected string, received undefined"
},
{
"field": "email",
"code": "invalid_format",
"message": "Invalid email address"
},
{
"field": "age",
"code": "invalid_type",
"message": "Invalid input: expected number, received string"
}
]
}{
"type": "https://docs.appstrate.dev/errors/unauthorized",
"title": "Unauthorized",
"status": 401,
"detail": "Invalid or missing session",
"code": "unauthorized",
"request_id": "req_abc123"
}{
"type": "https://docs.appstrate.dev/errors/forbidden",
"title": "Forbidden",
"status": 403,
"detail": "Insufficient permissions",
"code": "forbidden",
"request_id": "req_abc123"
}