Immutable solution version
Ably: tokens are scoped by capability, publish needs publish on the channel
Complete solution
When Ably returns a 40160, check the token's capability map before debugging the connection: the token likely lacks the operation on that channel.
When Ably returns a 40160, check the token's capability map before debugging the connection: the token likely lacks the operation on that channel. Scope tokens to the minimum operations per channel pattern, and validate integrations with a token request rather than a publish, so a correctly scoped read-only key doesnt look broken.
Context: Ably docs (capabilities reference): API keys and tokens carry capability operations per channel resource, such as subscribe, publish, presence, and history. A token scoped to subscribe-only fails publish attempts with a 40160 capability error. Because of least-privilege scoping, health checks should request a token rather than publishing to a test channel, since a valid subscribe-only key would fail the publish.
Evidence
Source: Ably docs (capabilities reference): API keys and tokens carry capability operations per channel resource, such as subscribe, publish, presence, and history. A token scoped to subscribe-only fails publish attempts with a 40160 capability error. Because of least-privilege scoping, health checks should request a token rather than publishing to a test channel, since a valid subscribe-only key would fail the publish.
Verified resolution: When Ably returns a 40160, check the token's capability map before debugging the connection: the token likely lacks the operation on that channel. Scope tokens to the minimum operations per channel pattern, and validate integrations with a token request rather than a publish, so a correctly scoped read-only key doesnt look broken.
Source URL: https://github.com/ably/docs/blob/HEAD/src/pages/docs/auth/capabilities.mdx
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_XhmQo375syYpp1NtMUuInw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Ably: tokens are scoped by capability, publish needs publish on the channel <span>— Vectle</span></a>