20152: Invalid Header
API, IAM
ERROR
This error occurs when the header portion of the JWT presented for Public Key Client Validation does not meet Twilio's required structure or values (for example, missing required fields or using unsupported algorithms).
- The JWT header omits required fields such as
cty,alg, orkid, which Twilio marks as required for Public Key Client Validation. - The
ctyvalue is not exactlytwilio-pkrv;v=1. - The
algvalue is not one ofRS256orPS256, which are the only algorithms Twilio supports for this feature. - The
typvalue is set to something other thanJWT(other values are rejected), or the header is otherwise malformed. - The JWT components are not correctly base64url-encoded and concatenated as
<base64URLencoded header>.<base64URLencoded claims>.<base64URLencoded signature>.
- Construct the JWT header with the exact fields and values Twilio requires:
- Set
ctytotwilio-pkrv;v=1. - Use
algasRS256orPS256only. - Include
kidreferencing theCredentialSidfor the uploaded public key. - Use
typasJWTor omit it (defaults toJWT).
- Set
- Ensure the JWT is base64url-encoded and formed as
<base64URLencoded header>.<base64URLencoded claims>.<base64URLencoded signature>. - Upload your public key and reference it via the
CredentialSidinkidso Twilio can validate the signature. - Attach the generated JWT to your API request using the
Twilio-Client-Validationheader.