---
updatedAt: 2025-09-22T21:34:14.000Z
agentTools:
  projectIndex: https://developers.digitalfemsa.io/llms.txt
---

# Authentication

API Keys are used to authenticate all requests against **OXXO pay** api using the [Bearer Authentication](https://swagger.io/docs/specification/authentication/bearer-authentication/).  API Keys can be recovered from [Panel](https://panel.digitalfemsa.io/).  Each key is configured for either sandbox or production modes, and each mode will have a public key and private key for making secure backend requests..

<HTMLBlock>{`
<div>
<p><span style="color: #ff0000;"><strong>Never share your private keys with anyone as it will allow them complete access to your account.</strong></span></p>  
</div>
`}</HTMLBlock>

Sandbox mode allows you to simulate payment flows without actually completing payments. Throughout our documentation we have provided examples with sandbox keys so that you can test your integration without creating a OXXO pay account.

For practicality we suggest using out **official libraries**, which are regularly updated to simply integration with the most recent version of the API in the following programming languages:

* [Ruby](https://github.com/digitalfemsa/digitalfemsa-ruby)
* [PHP](https://github.com/digitalfemsa/femsa-php)
* [Python](https://github.com/digitalfemsa/digitalfemsa-python)
* [Node](https://github.com/digitalfemsa/digitalfemsa-node)
* [Java](https://github.com/digitalfemsa/digitalfemsa-java)
* [.NET](https://github.com/digitalfemsa/digitalfemsa-.net)
* [Go](https://github.com/digitalfemsa/digitalfemsa-go)

**Remember that:**

1. [You can obtain you private key in Panel](https://developers.digitalfemsa.io/docs/como-obtener-tus-api-keys)

   * **Key\_LlavePRIVADA123456789**

2. You can use the following header to authenticate yourself

* **Authorization: Bearer Key\_LlavePRIVADA123456789**

<Image alt="Imagen 1: Una vista simple para obtener las llaves desde POSTMAN de Google, aquí declaramos variables de entorno." align="center" src="https://files.readme.io/40f3e25-image.png">
  Image 1: An example of how the authentication key can be set in Postman's Authorization section using an environment variable
</Image>

<Image alt="Imagen 2: Una vista simple para obtener las llaves desde POSTMAN de Google, aquí la herramienta las genera automáticamente, la imagen es informativa" align="center" src="https://files.readme.io/2247a46-image.png">
  Image 2: An example of how the Postman authentication key will be rendered as a header
</Image>

```asp cURL
curl --location --request POST 'https://api.digitalfemsa.io'/{API_endpoint}' \
//POST / PUT / GET / DEL son admitidas dependiendo del endpont a utilizar//
--header 'Accept: application/vnd.app-v2.1.0+json' \
--header 'Accept-Language: es' \
--header 'Content-Type: application/json' \
-u key_xxxxxxxxxxxxxx: \
--data-raw '{
//JSON REQUEST BODY
}'
```
```asp Ruby auth
require "uri"
require "json"
require "net/http"

url = URI("https://api.digitalfemsa.io/orders/{{orden_id}}/charges")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = "application/vnd.app-v2.1.0+json"
request["Content-type"] = "application/json"
request["Authorization"] = "Bearer key_xxxxxxx"
request.body = JSON.dump({})

response = https.request(request)
puts response.read_body
```
```c Php auth
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.digitalfemsa.io/charges',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => array(
    'Accept: application/vnd.app-v2.1.0+json',
    'Content-type: application/json',
    'Authorization: Bearer key_xxxxxx'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```
```c Python auth
import requests
import json

url = "https://api.digitalfemsa.io/orders/{{orden_id}}/charges"

payload = ""
headers = {
  'Accept': 'application/vnd.app-v2.1.0+json',
  'Content-type': 'application/json',
  'Authorization': 'Bearer key_xxxxx'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```
```c Node auth
var axios = require('axios');
var data = '';

var config = {
  method: 'post',
maxBodyLength: Infinity,
  url: 'https://api.digitalfemsa.io/orders/{{orden_id}}/charges',
  headers: { 
    'Accept': 'application/vnd.app-v2.1.0+json', 
    'Content-type': 'application/json', 
    'Authorization': 'Bearer key_xxxxx'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

```
```c Java auth
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://api.digitalfemsa.io/orders/{{orden_id}}/charges")
  .method("POST", body)
  .addHeader("Accept", "application/vnd.app-v2.1.0+json")
  .addHeader("Content-type", "application/json")
  .addHeader("Authorization", "Bearer key_xxxxxx")
  .build();
Response response = client.newCall(request).execute();
```
```c .NET auth
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.digitalfemsa.io/orders/{{orden_id}}/charges");
request.Headers.Add("Accept", "application/vnd.app-v2.1.0+json");
request.Headers.Add("Content-type", "application/json");
request.Headers.Add("Authorization", "Bearer key_xxxxx");
var content = new StringContent("", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

```
```c Go auth
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.digitalfemsa.io/orders/%7B%7Borden_id%7D%7D/charges"
  method := "POST"

  payload := strings.NewReader(``)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Accept", "application/vnd.app-v2.1.0+json")
  req.Header.Add("Content-type", "application/json")
  req.Header.Add("Authorization", "Bearer key_xxxxx")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```