Signing Requests
To sign
multipart/form-data
requests, see the section Signing Multipart Requests.
All requests to the Network and Management APIs must be signed and have a valid signature passed in the X-Signature
header. To generate the signature:
-
Construct the following string:
{method}\n{path}\n{headers}\n{bodyDigest}
, where:-
{method}
is the HTTP method, in uppercase. -
{path}
is the remainder of the URL following the host, including the query string (if present). -
{headers}
is the concatenation of the following headers (if present) in the form{lowercase(name)}:{strip(value)}\n
:Accept
Authorization
Content-Type
Host
-
{bodyDigest}
is the lowercased, hexadecimal representation of the SHA256 digest of the bytes of the request body (hashing an empty string if there is no body).
-
-
Create an HMAC-SHA256 cryptographic hash where the text to hash is the string you created in step 1, and the secret is the secret value associated with the API key being used to make the request.
-
Set the
X-Signature
header toV1 {signature}
where:{signature}
is the signature obtained in step 2 in hexadecimal, lowercased.
Instead of computing a real signature in Sandbox, you can use a magic header value:
X-Signature: sandbox:skip-signature-check
-
Set an
Authorization
header ofClient {CLIENT_ID} {KEY_ID}
where:{CLIENT_ID}
is the client ID value obtained from Cash App{KEY_ID}
is the Cash App identifier for the API key used to generate the signature in step 2
Webhook signatures: Webhook deliveries also contain an
X-Signature
header that is computed using the same process. This allows webhooks delivered by Cash App to be validated by computing the signature from the request payload and verifying that it matches theX-Signature
header
Signing Multipart Requests
To sign requests using the multipart/form-data
content type, use this modified signing algorithm:
-
Construct the following string:
{method}\n{path}\n{headers}\n{bodyDigest}
, where:-
{method}
is the HTTP method, in uppercase. -
{path}
is the remainder of the URL following the host, including the query string (if present). -
{headers}
is the concatenation of the following headers (if present) in the form{lowercase(name)}:{strip(value)}\n
:Accept
Authorization
Content-Type
(this should bemultipart/form-data
with no other parameters)Host
-
{bodyDigest}
is the lowercased, hexadecimal representation of the SHA256 digest of the bytes of therequest
object specified in the request body.
-
-
Create an HMAC-SHA256 cryptographic hash where the text to hash is the string you created in step 1, and the secret is the secret value associated with the API key being used to make the request.
-
Append a
text/plain
object namedsignature
to the request body, containing the valueV1 {signature}
where{signature}
is the value obtained in step 2 in hexademical and lowercased.This signature will take precedence over any
X-Signature
header present in the request.Instead of computing a real signature in Sandbox, you can use a magic value:
sandbox:skip-signature-check