Authentication
Example Request
The Afterpay Online API uses Basic HTTP Authentication, a simple authentication scheme built into the HTTP protocol, as specified by RFC 7617.
With the exception of Ping, all Online API endpoints require this form of authentication. Failure to correctly authenticate an API request will result in a “401 Unauthorized” response.
Consider the following example:
In conventional HTTP terms, “Merchant ID” is the username and “Secret Key” is the password.
Afterpay provides merchant accounts per region, and each merchant account has unique API credentials.
The credentials are joined by a colon character (without any spaces), then base64-encoded.
The Authorization header can then be formed by including the word Basic, followed by a single space character, followed by the base64-encoded credential pair.
Security Notice
Please note that the base64-encoding of the Authorization header is unrelated to security. All HTTP headers and bodies (for both requests and responses) between the Merchant and Afterpay are encrypted with TLS. The reason for base64-encoding is solely to comply with the RFC 7617 standard, which allows non-HTTP characters and multibyte strings to be used for Basic HTTP Authentication.