agentleFS
wittyreferencewittyreference/twilio-claude-plugin/skills/iam/SKILL.md

iam

Skill2 starsChanged 8 months agoMITView on GitHub

Twilio development skill: iam

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 6 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create Standard API keys via v2010 REST API or MCP tools <!-- verified: SK5d87b5ae created -->

    line 24
  2. Very specific:

    Create Restricted API keys via v1 IAM API with fine-grained per-endpoint permissions <!-- verified: SKfb70101d created with …

    line 25
  3. Distinctive:

    Create Main API keys via Console only (not REST API)

    line 26
  4. Distinctive:

    Use test credentials for free API testing (4 endpoints, magic phone numbers)

    line 31
  5. Distinctive:

    Use API key auth for all standard API operations (calls, SMS, phone numbers, etc.) <!-- verified: SK key successfully listed phone numbers …

    line 35
  6. Distinctive:

    Use secondary auth token for authentication while rotating primary <!-- verified: secondary token worked for account fetch -->

    line 36
  7. Distinctive:

    Secondary auth token works immediately: No propagation delay observed for API-level authentication.

    line 197
  8. Very specific:

    Serverless Functions have up to 1-minute propagation delay: If auth tokens are hardcoded in Functions environment variables (not using …

    line 199
  9. Very specific:

    No MCP tools for auth token rotation: Must use REST API directly against accounts.twilio.com/v1/AuthTokens/.

    line 221
  10. Very specific:

    No MCP tools for PKCV public key management: Must use REST API against accounts.twilio.com/v1/Credentials/PublicKeys.

    line 225
  11. Very specific:

    IAM MCP tools are P3 tier: Not loaded by default (default is P0 + validation).

    line 227

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

name: iam description: Twilio IAM development guide. Use when choosing authentication methods, managing API keys, rotating auth tokens, creating subaccounts, generating Access Tokens for client SDKs, or debugging 401/403 errors.

<!-- verified: twilio.com/docs/iam, twilio.com/docs/iam/api-keys, twilio.com/docs/iam/access-tokens, twilio.com/docs/iam/test-credentials, twilio.com/docs/iam/credentials/public-key-client-validation, twilio.com/docs/iam/api/account, twilio.com/docs/iam/api/keys, twilio.com/docs/iam/api/signing-keys, twilio.com/docs/iam/api/sub-account + live testing 2026-03-27 -->

Twilio IAM

Authentication, authorization, and account hierarchy for Twilio APIs. Covers API key types (Standard, Main, Restricted), Access Tokens for client SDKs, auth token rotation, subaccount isolation, test credentials, and Public Key Client Validation (PKCV).

Evidence date: 2026-03-27. Account prefix: AC...

Scope

CAN

  • Authenticate via three methods: Account SID + Auth Token, API Key + Secret, or PKCV (Enterprise/Security) <!-- verified: all three tested live -->
  • Create Standard API keys via v2010 REST API or MCP tools <!-- verified: SK5d87b5ae created -->
  • Create Restricted API keys via v1 IAM API with fine-grained per-endpoint permissions <!-- verified: SKfb70101d created with messaging/messages/read policy -->
  • Create Main API keys via Console only (not REST API)
  • Rotate auth tokens via secondary token creation and promotion (zero-downtime) <!-- verified: secondary token created, authenticated with it, deleted -->
  • Generate Access Tokens (JWT) for Voice, Video, Sync, and Conversations client SDKs
  • Manage subaccounts: create, suspend, close, reactivate (main account only) <!-- verified: subaccount creation blocked on subaccount with error 21101 -->
  • Transfer phone numbers between subaccounts using main account credentials
  • Use test credentials for free API testing (4 endpoints, magic phone numbers)
  • List/fetch/update/delete keys via REST API or MCP tools (list_api_keys, get_api_key, create_api_key, update_api_key, delete_api_key) <!-- verified: all CRUD operations tested -->
  • Manage signing keys via MCP (list_signing_keys, create_signing_key, delete_signing_key) <!-- verified: signing keys list returns same SK-prefixed keys -->
  • Upload PKCV public keys via Credentials API (POST /v1/Credentials/PublicKeys)
  • Use API key auth for all standard API operations (calls, SMS, phone numbers, etc.) <!-- verified: SK key successfully listed phone numbers -->
  • Use secondary auth token for authentication while rotating primary <!-- verified: secondary token worked for account fetch -->

CANNOT

<!-- verified: all CANNOT items live-tested 2026-03-27 unless noted -->
  • Standard keys cannot access /Accounts or /Keys endpoints — Returns 20003 "Authenticate" (401). Must use Auth Token or Main API Key for account management and key creation. <!-- verified: SK5d87b5ae returned 401 on both /Accounts and /Keys -->
  • No restricted key creation via v2010 API — The v2010 /Keys.json endpoint silently ignores KeyType=restricted and Policy parameters, creating a standard key instead. No error is returned. Use the v1 IAM API (POST https://iam.twilio.com/v1/Keys) for restricted keys. <!-- verified: SKa5b2af06 created via v2010 with KeyType=restricted had policy: null in v1 -->
  • Restricted keys cannot generate Access Tokens — Only Standard and Main keys can create client SDK tokens. <!-- verified: docs -->
  • No individual Access Token revocation — Tokens are valid until expiration (max 24h). To revoke, delete the API key that issued them (revokes all tokens from that key).
  • No MCP tools for restricted key creation — MCP create_api_key uses v2010 under the hood; it cannot set keyType or policy. Use REST API directly for restricted keys. <!-- verified: iam.ts source code shows client.newKeys.create() with no keyType param -->
  • No MCP tools for auth token rotation — No create_secondary_auth_token or promote_auth_token tools. Use REST API against accounts.twilio.com/v1/AuthTokens/. <!-- verified: REFERENCE.md tool inventory -->
  • No MCP tools for PKCV credential management — PublicKey CRUD on the Credentials API has no MCP tool equivalents.
  • Subaccounts cannot create sub-subaccounts — Error 21101 "Subaccounts cannot contain subaccounts". The hierarchy is flat: one main account with up to 1000 direct subaccounts. <!-- verified: POST /Accounts.json from test account (subaccount) returned 21101 -->
  • Subaccount credentials cannot access parent or sibling subaccounts — Each subaccount's auth token is scoped to its own resources only.
  • PKCV incompatible with Flex, Studio, and TaskRouter — Cannot enforce PKCV if you use these products. <!-- verified: docs -->
  • PKCV enforcement kills Auth Token authentication — Once enabled, all requests must use API Key + PKCV JWT. Auth Token requests stop working. <!-- verified: docs -->
  • Test credentials work with only 4 endpoints — Messages, Calls, IncomingPhoneNumbers, and Lookups. All other endpoints return 403 Forbidden. No status callbacks are triggered. <!-- verified: docs -->
  • API key secret shown only at creation — Cannot be retrieved after the initial response. Must store immediately. <!-- verified: SK5d87b5ae fetch returned no secret field -->
  • FriendlyName max 64 characters for keys — 65+ characters returns error 70001 "The request has constraint violations". <!-- verified: 64 chars OK (SKd950a663), 65 chars rejected with 70001 -->
  • Restricted keys limited to 100 permissions per key — Exceeding this limit is rejected at creation. <!-- verified: docs -->

Quick Decision

NeedUseWhy
Local development / quick testingAccount SID + Auth TokenSimplest setup; full access to all endpoints
Production server-to-serverStandard API Key + SecretIndividually revocable; don't expose main Auth Token
Least-privilege microserviceRestricted API Key (v1)Per-endpoint permission control; max 100 perms
Client-side Voice/Video/Sync SDKAccess Token (JWT)Short-lived (max 24h); scoped grants per product
Console-only admin operationsMain API KeyFull access including /Accounts and /Keys
Tenant isolation / multi-customerSubaccountsSeparate credentials, resources, and billing rollup
Free API testing in CITest credentialsNo charges; magic numbers for predictable outcomes
Zero-downtime auth rotationSecondary Auth Token + PromoteTwo valid tokens during rotation window
Enterprise request signingPKCV (Public Key Client Validation)Eliminates shared secrets; per-request JWT signing

Decision Frameworks

Choosing an Authentication Method

FactorAuth TokenStandard KeyRestricted KeyPKCV
Setup complexityNone (comes with account)One API callv1 API + policy designKeypair + credential upload + JWT per request
Revocation granularityRotation only (affects everything)Per-keyPer-keyPer-credential
Can create other keysYesNo (401)With /twilio/iam/api-keys/create permWith Main API Key
Can access /AccountsYesNo (401)With explicit permissionWith Main API Key
Can generate Access TokensYesYesNoYes (Main/Standard key needed)
Least-privilege supportNo (full access)No (all except /Accounts, /Keys)Yes (per-endpoint)No (auth method, not authz)
AvailabilityAll accountsAll accountsAll accounts (US region in Console)Enterprise + Security Edition only

API Key Types Compared

AttributeMainStandardRestricted
Creation methodConsole onlyConsole, REST (v2010 or v1), MCPConsole, REST (v1 only)
SID prefixSKSKSK
Secret format32 chars, base6232 chars, base6232 chars, base62
Access levelAll endpoints (equivalent to Auth Token)All except /Accounts and /KeysDefined by policy.allow array
Can create Access TokensYesYesNo
policy field (v1 API)nullnull{"allow": [...]}
flags field (v1 list)["rest_api", "signing"]["rest_api", "signing"]Not present in v1 list
Max permissionsN/AN/A100

Access Token Grants

GrantSDKRequired paramsKey constraint
VoiceGrantVoice JS/iOS/AndroidoutgoingApplicationSidNone
VideoGrantVideo JS/iOS/AndroidNone (room optional)API key must be in US1 region
SyncGrantSync JSserviceSidNone
ChatGrantConversations JSserviceSidNone

Access Token constraints:

  • Max TTL: 86,400 seconds (24 hours)
  • Algorithm: HS256 (HMAC-SHA256 with API key secret)
  • Identity: alphanumeric + underscore only for Voice
  • Voice: max 10 concurrent registrations per identity (11th evicts oldest)
  • Content type header: cty: twilio-fpa;v=1

Subaccount Isolation Model

OperationMain Account CredsSubaccount Creds
Access main account resourcesYesNo
Access subaccount v2010 resourcesYesYes (own only)
Access sibling subaccountYesNo
Access subdomain APIs (Studio, TaskRouter)No (need subaccount creds)Yes
Create sub-subaccountsN/ANo (error 21101)
Transfer phone numbersYesNo
Create API keys for subaccountYes (Auth Token)Yes (own Auth Token)

Auth Token Rotation

Zero-downtime rotation workflow using REST API (no SDK helper):

POST https://accounts.twilio.com/v1/AuthTokens/Secondary
→ Returns: { secondary_auth_token: "...", account_sid: "..." }
→ Both primary and secondary are valid simultaneously

POST https://accounts.twilio.com/v1/AuthTokens/Promote
→ Secondary becomes primary; old primary is deleted

DELETE https://accounts.twilio.com/v1/AuthTokens/Secondary
→ Deletes secondary without promoting (if rotation is aborted)

Restricted Key Permission Format

Permissions follow the pattern /twilio/{product}/{resource}/{action}:

{
  "allow": [
    "/twilio/messaging/messages/read",
    "/twilio/messaging/messages/list",
    "/twilio/messaging/messages/create",
    "/twilio/voice/calls/read",
    "/twilio/voice/calls/create"
  ]
}

read and list are separate permissions. read permits fetching a single resource by SID; list permits listing the collection. Error 70051 tells you exactly which permission is missing.

Invalid permission paths return error 70002: "assertion '/twilio/fakepermission/doesnotexist' is invalid".

Supported products: Studio, Voice, Conversational Intelligence, Voice Insights, SIP, Messaging, Phone Numbers, Regulatory Compliance, TaskRouter, Monitor, Lookup, Verify, Video, Event Streams, Usage Records, Serverless, IAM, Flex (private beta).

Test Credentials

Separate Account SID + Auth Token found in Console > Admin > Account management > API keys & tokens.

Supported endpoints only: Messages (create), Calls (create), IncomingPhoneNumbers (create), Lookups (fetch). Everything else returns 403. No status callbacks are triggered. Cannot sign into Twilio CLI.

See references/test-results.md for the full magic phone number table.

Gotchas

Key Management

  1. v2010 silently ignores restricted key params: Passing KeyType=restricted and Policy=... to POST /2010-04-01/.../Keys.json creates a standard key with no error. The key has policy: null when checked via v1. Only the v1 IAM API (POST https://iam.twilio.com/v1/Keys) supports restricted key creation. [Evidence: SKa5b2af06]
  2. Keys and SigningKeys are the same resource: Both v2010 endpoints (/Keys.json and /SigningKeys.json) return the same SK-prefixed keys. The v1 API shows flags: ["rest_api", "signing"] on standard keys, confirming dual purpose. There is no separate "signing-only" key type. [Evidence: SK5d87b5ae appeared in both list responses]
  3. Key secret is 32 chars, base62; auth token is 32 chars, hex: API key secrets use alphanumeric characters (base62). Auth tokens use lowercase hex characters only. Both are 32 characters. [Evidence: Ma9ZHnBHKYxFgDWbh5AcliMYdbJgxtjL vs ff5711b12ae90b6da1d9753da7959c2f]
  4. FriendlyName omission produces null, not a default: Creating a key without FriendlyName sets it to null, not a generated default name. [Evidence: SK40efc57a]
  5. FriendlyName max 64 chars enforced with generic error: Error 70001 "The request has constraint violations" — no field-level detail. [Evidence: 65-char name rejected]

Authentication Boundaries

  1. Standard API key auth returns 401 on /Accounts, not 403: The error is 20003 "Authenticate" with HTTP 401, which looks like bad credentials rather than a permissions issue. Misleading if you're debugging. [Evidence: SK5d87b5ae on /Accounts.json]
  2. MCP validate_environment shows "(unavailable — API key auth)" for account name: When authenticated via API Key, the account friendly name cannot be fetched because the /Accounts endpoint is blocked. The account SID is still available. [Evidence: validate_environment output]
  3. Restricted key read vs list are distinct permissions: /twilio/messaging/messages/read allows GET /Messages/{Sid} but NOT GET /Messages (the list). You need both /read and /list for full read access. Error 70051 names the exact missing permission. [Evidence: SKfb70101d could fetch SM335a923f but not list messages]

Auth Token Rotation

  1. Secondary auth token works immediately: No propagation delay observed for API-level authentication. Both primary and secondary tokens are valid simultaneously until promotion or deletion. [Evidence: secondary token ff5711... authenticated successfully for account fetch]
  2. Serverless Functions have up to 1-minute propagation delay: If auth tokens are hardcoded in Functions environment variables (not using context.getTwilioClient()), promoted tokens may take up to 1 minute to propagate. Premature requests return 403.

Subaccounts

  1. Subaccount cannot create subaccounts: Error 21101 "Subaccounts cannot contain subaccounts". The hierarchy is strictly one level deep. [Evidence: POST /Accounts.json from test account returned 21101]
  2. Subaccount limit is 1000 per main account by default: Contact Twilio support to increase.
  3. Closed subaccounts are deleted after 30 days: Resources (phone numbers, recordings) must be transferred before closure.
  4. Subdomain APIs require subaccount-specific credentials: Main account credentials cannot access studio.twilio.com or taskrouter.twilio.com resources on subaccounts. You need the subaccount's own SID + Auth Token.

PKCV

  1. PKCV JWT max expiration is 300 seconds (5 minutes): Much shorter than Access Token max of 86,400 seconds (24 hours). Each API request needs a fresh JWT.
  2. PKCV is Enterprise/Security Edition only: Attempting to enable it on standard accounts will not work.
  3. Enabling PKCV enforcement disables Auth Token authentication: This is irreversible in practice — you must have Main API Keys set up before enabling enforcement.

MCP Tool Gaps

  1. No MCP tools for auth token rotation: Must use REST API directly against accounts.twilio.com/v1/AuthTokens/.
  2. No MCP tools for restricted key management: create_api_key creates standard keys only. list_api_keys and get_api_key work for all key types but don't show the policy field (v2010 responses don't include it).
  3. No MCP tools for PKCV public key management: Must use REST API against accounts.twilio.com/v1/Credentials/PublicKeys.
  4. IAM MCP tools are P3 tier: Not loaded by default (default is P0 + validation). Configure toolTiers: ['P0', 'P3', 'validation'] or ['all'] to enable them.

Related Resources

MCP Tools

IAM tools (P3 tier): mcp__twilio__list_api_keys, mcp__twilio__get_api_key, mcp__twilio__create_api_key, mcp__twilio__update_api_key, mcp__twilio__delete_api_key, mcp__twilio__list_signing_keys, mcp__twilio__create_signing_key, mcp__twilio__delete_signing_key

Accounts tools (P3 tier): mcp__twilio__get_account, mcp__twilio__list_accounts, mcp__twilio__create_subaccount, mcp__twilio__update_account, mcp__twilio__list_usage_records, mcp__twilio__get_account_balance

Validation: mcp__twilio__validate_environment (checks account identity, credentials, service SIDs)

Cross-References

  • MCP server tool source: twilio/src/tools/iam.ts, twilio/src/tools/accounts.ts
  • MCP tool reference: twilio/REFERENCE.md §IAM Tools, §Accounts Tools
  • Tool boundaries: references/tool-boundaries.md
  • Environment invariants: rules/environment-invariants.md
  • Twilio CLI skill: skills/twilio-cli/SKILL.md (profiles, deployment — CLI-only operations)

Reference Files

TopicFileWhen to read
Live test resultsreferences/test-results.mdWhen you need SID-level evidence for specific IAM behaviors
Assertion auditreferences/assertion-audit.mdWhen verifying provenance of any claim in this skill

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.