# API Basics source: https://developer.mastercard.com/transactions-service/documentation/api-basics/index.md ## API Security {#api-security} ### Client Authentication {#client-authentication} Warning: **Key Lifecycle:** Loyalty Transactions Service supports **OAuth 1.0a** authentication. You can renew or rotate Sandbox and Production keys from your [Developer Dashboard](https://developer.mastercard.com/dashboard). You do not need to create a new project each time keys are updated. | Authentication Protocol | Details | |--------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [OAuth 1.0a](https://oauth.net/core/1.0a/) | Mastercard uses OAuth 1.0a with a body hash extension for authenticating the API clients. OAuth 1.0a is an authentication and authorization protocol that guarantees the integrity and authenticity of incoming API calls and allows for non-repudiation of requests. | OAuth requires every request that you send to Mastercard to be signed with an RSA private key. A private-public RSA key pair must be generated consisting of: 1. A **private key** for the OAuth signature for API requests. It is recommended to keep the private key in a password-protected or hardware keystore. Data encrypted using a public key can only be decrypted using the corresponding private key. 2. A **public key** is shared with Mastercard during the project setup process through either a certificate signing request (CSR) or the API Key Generator. Mastercard will use the public key to verify the OAuth signature that is provided on every API call. * Requests with a body must be signed using the [Google Request Body Hash](https://datatracker.ietf.org/doc/id/draft-eaton-oauth-bodyhash-00.html) extension for OAuth. * The OAuth keys for your project can be set up on your project dashboard here ([Developer Dashboard](https://developer.mastercard.com/dashboard)), after you create a project. Tip: Do you want to learn more about the authentication scheme Mastercard uses? For that, read our [Using OAuth 1.0a to Access Mastercard APIs](https://developer.mastercard.com/platform/documentation/authentication/using-oauth-1a-to-access-mastercard-apis/) guide. Note: **Dual Authentication Support** Loyalty Transactions Service APIs support **OAuth 1.0a** at the project level. A project can be configured to use either protocol individually, or both simultaneously, with no preference or migration requirement implied between them. ## Encryption {#encryption} The transport between client applications and Mastercard is secured using [TLS/SSL](https://en.wikipedia.org/wiki/Transport_Layer_Security), which means data is encrypted by default when transmitted across networks. Whereas sensitive data like card numbers (Payment Card Industry Data Security Standard) are sent, the entire request payload should be encrypted using the JWE encryption scheme. For further details, please refer to [Securing Sensitive Data Using Payload Encryption.](https://developer.mastercard.com/platform/documentation/security-and-authentication/securing-sensitive-data-using-payload-encryption/) ### Encryption Libraries {#encryption-libraries} Mastercard has abstracted the encryption scheme into our [client encryption libraries](https://developer.mastercard.com/platform/documentation/security-and-authentication/securing-sensitive-data-using-payload-encryption/#client-libraries), which are available in several of the most used development languages. We highly recommend that you utilize these libraries to encrypt the sensitive data used by this service. ## How to Consume the Loyalty Transactions Service? {#how-to-consume-the-loyalty-transactions-service} Note: There are multiple ways of integrating with the Loyalty Transactions Service: 1. Using a generated API client (recommended) 2. Using a method of your choice ### Generating your own API client {#generating-your-own-api-client} Create customizable API clients from the Loyalty Transactions Service specification and let Mastercard open-source client libraries handle the authentication for you. This approach offers more flexibility and is strongly recommended. For this, please follow our [Generating and Configuring a Mastercard API Client](https://developer.mastercard.com/platform/documentation/security-and-authentication/generating-and-configuring-a-mastercard-api-client/) tutorial with the following API specification: [mrs-transactions-service-swagger.yaml](https://static.developer.mastercard.com/content/transactions-service/swagger/mrs-transactions-service-swagger.yaml) (15KB) ### Using a method of your choice {#using-a-method-of-your-choice} Loyalty Transactions Service exposes a REST API: you are free to use the REST/HTTP client of your choice and can still leverage the Mastercard open-source [client authentication](https://developer.mastercard.com/platform/documentation/security-and-authentication/using-oauth-1a-to-access-mastercard-apis/#client-libraries) and [client encryption](https://developer.mastercard.com/platform/documentation/security-and-authentication/securing-sensitive-data-using-payload-encryption/#client-libraries) libraries for signing your requests and dealing with payload encryption. For that, please refer to the Loyalty Transactions Service [REST API Reference](https://developer.mastercard.com/transactions-service/documentation/api-reference/index.md). ## Environments {#environments} The table below describes the two different environments that are available. | **Environment** | **Base URL** | **Description** | |-----------------|--------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Sandbox | `https://sandbox.api.mastercard.com/loyalty/mrs` | Pre-production test environment containing the latest pre-release version of the real APIs, intended for full integration testing prior to moving to production. Use your Sandbox keys to authenticate with this environment. The keys are set up when you create your project. | | Production | `https://api.mastercard.com/loyalty/mrs` | Full production environment containing the latest production API release. Use approved Production credentials. | Append `/transactions/searches` to the selected base URL for the transaction search operation. ## Next Steps {#next-steps} Follow the [Quick Start Guide](https://developer.mastercard.com/transactions-service/documentation/quick-start-guide/index.md) for a Sandbox request, or [Integration and Testing](https://developer.mastercard.com/transactions-service/documentation/tutorials-and-guides/api-testing-tutorial/index.md) to integrate a generated Java client. Use [Code and Formats](https://developer.mastercard.com/transactions-service/documentation/code-and-formats/index.md) to resolve failed requests. After Sandbox validation, follow [Production Access](https://developer.mastercard.com/transactions-service/documentation/tutorials-and-guides/production-access-tutorial/index.md).