Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Authentication

Configure RSA credentials and sign requests to the MusePay API.

MusePay authenticates API requests with RSA signatures. You generate and retain the private key, then upload the corresponding public key to MusePay. MusePay never needs access to your private key.

Generate an RSA key pair

Generate a 2048-bit RSA private key in PKCS #8 PEM format, then export its public key:

openssl genpkey -algorithm RSA -out muse_secret.key -pkeyopt rsa_keygen_bits:2048
openssl pkey -in muse_secret.key -pubout -out muse_public.key

A private key file has the following format. The middle of this example is masked and is not a usable key:

-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSj...REDACTED...AQAB
-----END PRIVATE KEY-----

Open the Partner Portal, go to the API Key tab, and configure your partner public key by uploading the contents of muse_public.key. MusePay uses this key to verify your API request signatures.

Before uploading, remove the -----BEGIN PUBLIC KEY----- and -----END PUBLIC KEY----- lines, then remove all line breaks. Upload only the remaining Base64-encoded public key as a single line.

Partner Portal API Key page showing the Partner ID and public-key configuration
Configure your public key and download the MusePay public key in the Partner Portal.

Download and store the MusePay public key as well. You use the MusePay public key—not your partner public key—to verify signed webhook notifications.

Required authentication fields

Include the following fields in every API request body. Endpoint-specific fields must be included in the same body before the signature is generated.

Name
Type
Description

partner_id

String

Partner ID shown in the Partner Portal.

sign_type

String

Fixed value: RSA.

timestamp

String

Current 10-digit Unix timestamp in seconds.

nonce

String

Unique random value for this request. Do not reuse a nonce; duplicates within 60 seconds are rejected.

sign

String

Base64-encoded RSA signature generated as described below.

See Common Parameters for the shared request-field reference.

Build the signature

Use the exact request values that you will send to MusePay:

  1. Remove the sign field.

  2. Exclude fields whose values are null or an empty string.

  3. Sort the remaining fields by field name in ascending, case-sensitive alphabetical order.

  4. Format each field as key=value and join the pairs with &. Do not URL-encode this canonical string.

  5. Encode the canonical string as UTF-8 and sign it with your RSA private key using SHA1WithRSA.

  6. Base64-encode the generated signature and send it as sign.

Example payload

The unsigned request body:

The canonical string is:

After signing, add the Base64-encoded result to the request body:

Code examples

The examples below read the private key from muse_secret.key. Keep this file outside your source repository and restrict access to it.

Java
JavaScript (Node.js)
PHP

Troubleshooting signature errors

If MusePay rejects a signature, verify that:

  • the public key uploaded in the Partner Portal matches the private key used to sign the request;

  • the canonical string contains every non-empty request field except sign;

  • field names and values exactly match the final request body;

  • fields are sorted by name and are not URL-encoded;

  • the content is UTF-8 encoded and signed with SHA1WithRSA;

  • timestamp is a 10-digit Unix timestamp in seconds; and

  • a new nonce is generated for every request.

Last updated