{"record":{"id":"2acd1ae14de91e86","repo":"clockworklabs/SpacetimeDB","slug":"you-need-to-be-logged-in-as-the-owner-of-name-to","errorCode":null,"errorMessage":"You need to be logged in as the owner of {name} to publish to {name}","messagePattern":"You need to be logged in as the owner of (.+?) to publish to (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/publish.rs","lineNumber":663,"sourceCode":"                let op = match op {\n                    PublishOp::Created => \"Created new\",\n                    PublishOp::Updated => \"Updated\",\n                };\n                if let Some(ref domain) = domain {\n                    println!(\"{op} database with name: {domain}, identity: {database_identity}\");\n                } else {\n                    println!(\"{op} database with identity: {database_identity}\");\n                }\n\n                if is_maincloud_host(&database_host)\n                    && let Some(domain) = domain.as_ref()\n                {\n                    println!(\"Dashboard: https://spacetimedb.com/{}\", domain.as_ref());\n                }\n            }\n            PublishResult::PermissionDenied { name } => {\n                if anon_identity {\n                    anyhow::bail!(\"You need to be logged in as the owner of {name} to publish to {name}\",);\n                }\n                // If we're not in the `anon_identity` case, then we have already forced the user to log in above (using `get_auth_header`), so this should be safe to unwrap.\n                let token = config.spacetimedb_token().unwrap();\n                let identity = decode_identity(token)?;\n                //TODO(jdetter): Have a nice name generator here, instead of using some abstract characters\n                // we should perhaps generate fun names like 'green-fire-dragon' instead\n                let suggested_tld: String = identity.chars().take(12).collect();\n                return Err(anyhow::anyhow!(\n                    \"The database {name} is not registered to the identity you provided.\\n\\\n                    We suggest you push to either a domain owned by you, or a new domain like:\\n\\\n                    \\tspacetime publish {suggested_tld}\\n\",\n                ));\n            }\n        }\n    }\n\n    Ok(())\n}","sourceCodeStart":645,"sourceCodeEnd":681,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/publish.rs#L645-L681","documentation":"The server answered the publish request with `PublishResult::PermissionDenied { name }`, and the CLI is running anonymously — no login token is stored, so `anon_identity` is true. Because an anonymous identity can never own a named database, the CLI immediately bails with this message instead of trying to decode an identity from a nonexistent token.","triggerScenarios":"Publishing to a named database (e.g. `spacetime publish mydb -s maincloud`) that is registered to some other identity while `config.spacetimedb_token()` is absent — fresh install, after `spacetime logout`, or a cleared config directory.","commonSituations":"New machine or container without prior `spacetime login`; publishing to a domain name claimed by a teammate or another account; assuming the CLI is logged in after reinstalling.","solutions":["Run `spacetime login` and retry the publish","Confirm who you are with `spacetime identity show` and verify it matches the owning account","If the database belongs to someone else, publish under your own new domain name instead","Check `spacetime server list` to make sure you are publishing to the server where you actually own the database"],"exampleFix":"# before\nspacetime publish mydb -s maincloud   # PermissionDenied, anon\n# after\nspacetime login\nspacetime publish mydb -s maincloud","handlingStrategy":"try-catch","validationCode":"# Fail fast before publishing if not logged in\nspacetime identity show >/dev/null 2>&1 || { echo 'not logged in'; spacetime login; }","typeGuard":null,"tryCatchPattern":"// Wrapping the publish call in a script/pipe: detect the auth case and route to login\nlet out = run_cli(\"spacetime publish db\");\nif out.contains(\"You need to be logged in\") {\n    run_cli(\"spacetime login\"); // interactive\n    out = run_cli(\"spacetime publish db\");\n}","preventionTips":["Run `spacetime login` as the first step of any publish workflow on a new machine","Check `spacetime identity show` before publishing to named databases","Script non-interactive flows to abort on auth prompts rather than loop"],"tags":["spacetimedb","publish","authentication","permission-denied","cli"],"backgroundTag":"authentication-required","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}