WebstoryDocs

Authentication

How agents and apps sign in to Webstory with OAuth 2.1 and PKCE, which scopes exist, and what a token can and can't do.

Webstory is its own OAuth authorization server for the MCP server and the REST API. If your agent app supports remote MCP servers with OAuth, it does all of this for you, and you only need Connect an agent. This page is for developers building their own client.

The flow

Webstory follows OAuth 2.1 and the MCP authorization spec:

  1. Discover. A request without a token gets 401 Unauthorized with a WWW-Authenticate: Bearer header whose resource_metadata points to the protected resource metadata (RFC 9728). That document names Webstory's authorization server, whose metadata (RFC 8414) lists the sign-in endpoints.
  2. Register. Your client registers itself with dynamic client registration (RFC 7591) at the registration endpoint, with client_name (1 to 80 characters, shown to the person) and 1 to 5 redirect_uris: https addresses, or http on localhost, 127.0.0.1 or [::1] for an app on the person's computer. Neither may contain "Webstory". Clients are public: there's no client secret, and PKCE protects the code instead. A client that nobody connected and that sent no request for 90 days is removed: if Webstory answers invalid_client, register again.
  3. Authorize. Send the person to the authorization endpoint with the authorization code flow and PKCE. Only the S256 code challenge method is accepted. Include resource with the exact address you want a token for, with no trailing slash: https://webstoryapp.com/mcp for the MCP server, or https://webstoryapp.com/api/v1/agent for the REST API. The person signs in, chooses a workspace, can switch off any of the scopes you asked for, and approves. If you ask for no scope, every agent scope is offered.
  4. Get tokens. Exchange the code at the token endpoint. The response says which scopes the person actually granted, which may be fewer than you asked for.
  5. Call. Send the access token as Authorization: Bearer <token> on every request. Tokens never go in a URL.

The authorization response includes iss (RFC 9207). Check that it is https://webstoryapp.com before you use the code. Problems with the request itself, such as a wrong redirect_uri, are shown to the person on Webstory's page and never sent back to your client.

Endpoints

Remote MCP (Streamable HTTP)https://webstoryapp.com/mcp
REST mirrorhttps://webstoryapp.com/api/v1/agent/…
Protected resource metadata (MCP)https://webstoryapp.com/.well-known/oauth-protected-resource/mcp
Protected resource metadata (REST)https://webstoryapp.com/.well-known/oauth-protected-resource/api/v1/agent
Authorization server metadata (issuer)https://webstoryapp.com/.well-known/oauth-authorization-server
Client registration (RFC 7591)https://webstoryapp.com/api/oauth/register
Authorizationhttps://webstoryapp.com/oauth/authorize
Tokenhttps://webstoryapp.com/api/oauth/token
Revocation (RFC 7009)https://webstoryapp.com/api/oauth/revoke
Signing keys (notifications)https://webstoryapp.com/.well-known/jwks.json
OpenAPI description of the REST mirrorhttps://webstoryapp.com/api/v1/openapi.json
Tool list with schemashttps://webstoryapp.com/api/v1/tools.json

Tokens

  • Access tokens last one hour. Use the refresh token to get a new one.
  • Refresh tokens can be used once. Each refresh returns a new pair: store both and drop the old ones. Using an old refresh token again ends the connection, because it suggests the token was copied.
  • When a refresh fails with invalid_grant, the connection has ended. Send the person through the flow again.
  • A connection that isn't used for 90 days ends by itself.
  • Connecting the same client again for the same person and workspace replaces the earlier connection.
  • A token is bound to the resource it was issued for. A token for the MCP server isn't accepted by the REST API, and the other way round.
  • Redirect addresses must match the registered ones exactly. For apps on the person's own computer, http://localhost and http://127.0.0.1 redirects may use any port.

To end a connection from your side, revoke either token at the revocation endpoint (RFC 7009). That ends the whole connection.

Scopes

Ask only for what you need. The approval page leaves off any scope the person's role can't use, and the token response lists the scopes actually granted.

ScopeLets the agentTeam roles
stories:readSee your stories, their chapters and reels, and their linksEveryone who can see the workspace's stories
stories:shareMake links to your reels for sending to peopleEveryone who can see the workspace's stories
stories:editChange your stories’ drafts: add, arrange and edit reels, their words and buttons. Nothing goes live until someone publishes itOwners, Admins and Editors
insights:readSee how your stories are doingOwners, Admins, Editors and Viewers
comments:readRead the comments on your storiesOwners, Admins and Editors
chats:readRead the chats with your brandsOwners, Admins, Editors and Shop managers
orders:readSee your orders: number, date, items, total, status and the buyer’s first nameOwners, Admins and Shop managers
media:readSee the photos and videos in your libraryOwners, Admins and Editors
media:uploadAdd photos and videos to your libraryOwners, Admins and Editors
notificationsTell you about new orders, comments and messages you choose in Settings → NotificationsEveryone
offline_accessKeep working without asking you to connect again, until you disconnect it or it goes unused for 90 daysEveryone

Roles and what a token can do

A token works for one person in one workspace. What it can do is what both of these allow:

  • the scopes the person approved, and
  • the person's team role in that workspace, checked again on every request.

So a scope only works for the roles shown in the table above. A Viewer's agent can look at stories but never change them, and a Shop manager's agent sees shop data but not story numbers, just as in the dashboard. See Workspaces and roles.

A token can't:

  • reach another workspace. Anything outside its workspace answers as if it didn't exist;
  • sign in to the dashboard, or use its pages;
  • do anything the person couldn't do themselves;
  • touch keys and secrets, payments and payouts, bank details, billing, team members, handovers, refunds or ad tracking, or delete a workspace. No scope opens these.

If the person's role changes, they leave the workspace, or they disconnect the agent in Settings → AI agents, the change applies on the token's next request.

Errors while signing in

What happensWhat to do
401 with WWW-Authenticate on a callThe access token is missing, expired or for another resource. Refresh it, or start the flow again.
403 with error="insufficient_scope"The connection doesn't have the scope this call needs. If the person's role allows it, ask them to connect again and approve it.
invalid_grant from the token endpointThe code or refresh token was used already, expired, or the connection ended. Start the flow again.
temporarily_unavailable (503) from the token endpointAgents can't work in that workspace right now. Keep the refresh token and try again later: the connection stays.

Other errors are on Errors.