← All Posts
Automation2026-11-09

Give a Social Agent Its Own Model Key, With an Expiry and a Cap

A setup procedure for the credential that pays for drafts, and a revoke test to run before you connect an account

Social media apps
Social media apps

*Image: Social media apps by Theresepersonne, licensed under CC BY-SA 4.0.*

A model key pasted into a social agent's settings is a payment credential and an identity. It bills your provider account for every draft the agent writes, and it tells the provider's API that the request comes from you. The key outlives the session that created it.

The agent needs the key to work at all, and some key types keep working after the person who set them up is gone. On Anthropic, a workspace key (a legacy key without an owner) continues to work when its creator is removed, and a service account key keeps working even if the user who created it is removed. Personal keys stop working shortly after their user is removed from a workspace and are archived when the user leaves the organization, and archiving a workspace archives every API key created for it (workspaces, captured 9 November 2026). Setting the name, the scope, the expiry and the cap is a bounded task that ends with one line in a key register.

What a model key authorizes

A provider account usually carries two kinds of limit, and they answer different questions. Spend limits cap the monthly cost an organization can incur for API usage. Rate limits cap how many requests the organization can make in a period (Anthropic rate limits and spend limits, captured 9 November 2026). The spend cap is the number that matters for a leaked key, because it bounds the bill.

On Anthropic's standard tiers the monthly spend caps are $500 on Start, $1,000 on Build and $200,000 on Scale, with no cap on the Custom tier. When usage reaches the tier's cap, API usage pauses until 00:00 UTC on the first day of the next month and requests return HTTP 429. Organizations can also set their own lower limit on the billing page, and can set user-configurable limits for individual workspaces (rate limits, captured 9 November 2026).

Scope comes from workspaces. Anthropic's workspace documentation states that an API key can be scoped to a single workspace, and with that scope it can only access resources inside that workspace. A key without that scope runs in the workspace named by each request's anthropic-workspace-id header, and the key's user or service account must have access to that workspace (workspaces, captured 9 November 2026). The single-workspace scope is the boundary the provider enforces for the key.

OpenAI's public guidance covers similar ground with stricter language about sharing. Each team member should use a unique key, and sharing keys is against the Terms of Use. Project keys can be created with an expiration date, administrators can enforce a maximum key lifetime at the organization or project level, and the recommended rotation sequence is to create a replacement, update the application, verify, then revoke the old key. Spend limits can be enforced at the organization or project level, and OpenAI notes that spend alerts alone do not stop API traffic while hard enforcement can block legitimate requests (best practices for API key safety, captured 9 November 2026).

Two credentials sit between you and a published post

A social agent that writes posts from a model uses one key to generate text and another to publish. SMM Agent's home page describes the model side as storing tested model keys per workspace and selecting only models unlocked by active keys (home page, captured 9 November 2026). Its posting docs describe the publishing side: bearer keys are workspace scoped, Read & Write permission is required for posting, and the publish call should stay behind explicit user approval. The drop-in instructions for agents include a line that says never print the API key (posting docs, captured 9 November 2026).

OpenAI warns that a compromised key "allows a person to gain access to your account quota, without your consent," which can result in unexpected charges and a depletion of the monthly quota (best practices for API key safety, captured 9 November 2026). A posting key that leaks can publish to connected accounts. Each one needs its own scope, its own expiry and its own record. Keeping both in one secret store entry or one environment file means a single exposure leaks the ability to generate text and the ability to publish at the same time.

Four choices before the first draft

Name the key after the thing it serves. Use a pattern you can read a year later, such as the agent name, the environment and the creation month: smm-agent-prod-2026-11. The name is what shows up in a provider console during an incident, when nobody remembers which key belongs to which cron job.

Scope it to the narrowest place that still works. Where the provider supports workspace-scoped keys, put the agent's key in a workspace created for the agent so a leak cannot reach unrelated projects. A workspace-scoped key can still reach every resource inside that workspace, so keep other projects out of it. On Anthropic that workspace has to be a dedicated one, because you can't set spend limits on the Default Workspace. Organization-wide limits always apply on top of whatever the workspace carries.

Put an expiry on it. OpenAI documents an expiration date on project keys and an administrator-enforced maximum lifetime. The Anthropic pages cited here describe no key-level expiry, so there the date lives in your register and you honor it at rotation. Either way, set the date before you need it and put the replacement date in the same calendar as the account review.

Cap the spend at the amount you would accept losing in a month. Spend caps sit at the organization, workspace or project level, so every key in the same workspace or project shares one cap. That is a second reason to give the agent its own workspace or project. On Anthropic the rate limits page describes user-configurable spend limits for workspaces alongside the tier cap, and a workspace limit can be set lower than the organization's limit but not higher. On OpenAI it means a project spend limit with hard enforcement turned on, with the tradeoff stated in their own docs: enforcement can block legitimate requests, and spend may slightly exceed the limit because it is not instantaneous.

Record all four in one register, one line per key. The cap line records the limit of the workspace or project the key lives in:

key: smm-agent-prod-2026-11
provider: anthropic
scope: workspace wrkspc_... (dedicated, not Default)
workspace monthly cap: 40 USD
expires: 2026-12-09
owner: <person who can revoke it>
used by: agent name, environment, scheduler

The revoke test

The test measures what the agent does when the key stops working, which is the state you will be in during an incident.

1. Create a throwaway workspace or project with the lowest spend cap your provider allows, create a throwaway key scoped to it, and mark both for deletion within a day. On Anthropic this cannot be the Default Workspace, and archiving the throwaway workspace later archives every key created for it. 2. Run the agent's normal path: one draft from a source, one scheduled post, one publish call that you approve. 3. Note the provider's usage page before and after, so you know the cost of one cycle. A throwaway workspace keeps that number separate from your other traffic. 4. Revoke the key in the provider console. 5. Re-run the same path. Record what fails loudly with an error, what fails silently into a queue that will retry, and which step still succeeds on the posting credential alone. 6. Test offboarding in two parts, each with a fresh throwaway key in the same workspace. - First, remove the person who created the key and re-run the draft step. On Anthropic a service account key keeps working even if the user who created it is removed, so a passing draft shows that offboarding that person leaves the agent running. A personal key stops working shortly after its user is removed, so an agent on a personal key fails here. A legacy workspace key keeps working. - Second, remove the service account itself from the workspace and re-run the draft step. A service account key stops working shortly after its service account is removed, so this run shows how the agent behaves when you cut it off deliberately. 7. Write each observed outcome next to the step it affects.

Read the outcomes as a monitoring list. A draft that fails with a clear error needs no watcher. A queue that retries silently needs an alert on repeated provider errors, because a revoked key plus a retry loop can look like a quiet week until someone notices nothing has published. A scheduled post that still goes out after the model key is revoked shows that the queue publishes the saved draft without calling the model at send time. A scheduled post that fails shows that the queue regenerates or edits content when it sends, so every scheduled item depends on the model key staying live through its send time, which sets how long the rotation overlap has to be.

Rotation that does not strand a scheduled post

OpenAI's rotation sequence is sequential for a reason: create the replacement, update the application, verify that requests succeed, then revoke the old key. A social agent with a scheduled queue needs the overlap window to be long enough to cover the next scheduled item, or the post fails while the new key sits unused in the settings page.

OWASP's secrets management guidance recommends automating rotation where possible and lists rotation strategies that include scheduled and rapid rotation (OWASP Secrets Management Cheat Sheet, captured 9 November 2026). It also lists eight items an audit trail should cover at a minimum. Four of them apply directly here: who requested a secret and for what system and role, when the secret was used and by whom, when it expired, and whether there were attempts to reuse an expired secret.

Those four items fit the key register above. The owner field answers the first. The provider's usage reporting answers the second at workspace level. Anthropic's usage and cost reporting identifies the workspace a row belongs to, and OpenAI tracks team usage on its Usage page. The expiry column answers the third. The fourth needs one check after each rotation: once the old key is revoked, search the agent's and the scheduler's own logs for authentication errors. Any process still holding the old value fails there, and a retry loop that keeps presenting the revoked key is the clearest signal that something missed the update. That is exactly the failure the overlap window hides from you.

What these limits leave out

A workspace spend limit caps monthly spending for that workspace, and the organization's own limit still applies on top. A key scoped to a workspace can only access resources within that workspace, which still includes every resource there. A key without the scope can run in any workspace its user or service account can access, chosen per request by the anthropic-workspace-id header. Both providers document scoping at the workspace or project level. Permission controls narrow what a key can do: OpenAI lets you assign permissions to individual API keys, and SMM Agent requires a Read & Write level for keys that post. Neither control records which agent holds a key or when it should be replaced, so naming and rotation still fall to the operator.

Network controls help only when the agent runs on infrastructure you control. OpenAI's IP allowlisting allows only requests from configured addresses or ranges and rejects all others, even when they carry a valid key. That makes it practical only when the agent runs from stable, known addresses, such as backend servers or a cloud environment. Their Private Link option is not compatible with IP allowlisting or mutual TLS, so a team that needs private networking gives up the address restriction.

The register, the expiry and the revoke test fit on one page. Do the revoke test before you connect a real account, because it is the only part that tells you which failures are loud and which ones are silent, and a silent failure is what lets the agent stop publishing without anyone noticing.

Ready to automate your social posting?

Sign in to create, schedule, publish, and get help from the dashboard.

Start using SMM Agent
Give a Social Agent Its Own Model Key, With an Expiry and a Cap — SMM Agent | SMM Agent