{"record":{"id":"5ed7f3cb461f22d0","repo":"clockworklabs/SpacetimeDB","slug":"permission-denied-for-domain-domain","errorCode":null,"errorMessage":"Permission denied for domain: {domain}","messagePattern":"Permission denied for domain: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/dns.rs","lineNumber":53,"sourceCode":"    let domain: DomainName = domain.parse()?;\n\n    let builder = reqwest::Client::new()\n        .put(format!(\n            \"{}/v1/database/{database_identity}/names\",\n            config.get_host_url(server)?\n        ))\n        .header(reqwest::header::CONTENT_TYPE, \"application/json\")\n        .body(serde_json::to_string(&[&domain])?);\n    let builder = add_auth_header_opt(builder, &auth_header);\n\n    let response = builder.send().await?;\n    let status = &response.status();\n    let result: SetDomainsResult = response.json_or_error().await?;\n\n    if !status.is_success() {\n        anyhow::bail!(match result {\n            SetDomainsResult::Success => \"\".to_string(),\n            SetDomainsResult::PermissionDenied { domain } => format!(\"Permission denied for domain: {domain}\"),\n            SetDomainsResult::PermissionDeniedOnAny { domains } =>\n                format!(\"Permission denied for domains: {domains:?}\"),\n            SetDomainsResult::DatabaseNotFound => format!(\"Database {database_identity} not found\"),\n            SetDomainsResult::NotYourDatabase { .. } =>\n                format!(\"You cannot rename {database_identity} because it is owned by another identity.\"),\n            SetDomainsResult::OtherError(err) => err,\n        });\n    }\n\n    println!(\"Name set to {domain} for identity {database_identity}.\");\n\n    Ok(())\n}\n","sourceCodeStart":35,"sourceCodeEnd":67,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/dns.rs#L35-L67","documentation":"Response mapping for `spacetime rename` (`PUT /v1/database/{identity}/names`): the server answered non-success and the `SetDomainsResult` body was `PermissionDenied { domain }` — the authenticated identity is not allowed to claim the requested domain name. Domains are a flat namespace with per-domain ownership/permissions, so a name can be taken or restricted even though the database itself is fine.","triggerScenarios":"Renaming a database to a domain name owned or reserved by someone else, or one restricted by the host (e.g. trying to claim `myteam` when only members of that organization may use it); a typo landing on an existing domain.","commonSituations":"Choosing names that collide with other tenants on shared servers (maincloud); namespace policy changes on the host; assuming unpublished names are free when they are reserved.","solutions":["Pick a different, more specific new name (e.g. prefix with your org/user handle)","If you believe you should own the domain, verify you are logged in as the right identity (`spacetime login`, `spacetime identity show`)","Check for typos in the `--to` value — a mistyped existing name will read as 'permission denied'","Contact the server operator if the name is yours but incorrectly assigned"],"exampleFix":"# before\nspacetime rename --to shared-name <db-identity>\n# after\nspacetime rename --to acme-shared-name <db-identity>","handlingStrategy":"try-catch","validationCode":"# Probe availability cheaply before rename (name collision check)\nspacetime list | grep -q \"$(spacetime rename --to x 2>/dev/null)\" || true  # ultimately the server is authoritative","typeGuard":null,"tryCatchPattern":"// Match the bail message and branch: 'Permission denied for domain' -> prompt for a different name; do not retry the same domain.","preventionTips":["Namespace your domains (org/user prefix) on shared servers","Verify the active identity before renaming"],"tags":["cli","dns","rename","permissions","spacetimedb"],"backgroundTag":"permission-denied","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}