---
updatedAt: 2026-03-03T17:20:41.000Z
agentTools:
  projectIndex: https://docs.dlocal.com/llms.txt
---

# Security

How to make safe payment requests.

All Payouts API requests must use specific information and follow certain security protocols. This section provides a comprehensive guide to payout security requirements, including the necessary endpoints and their signatures.

<br />

***

# Security considerations

When implementing security measures for payouts, **it is important to note that some endpoints share security protocols with those used in Payins**.

<br />

> Endpoint-specific security requirements can be verified on their respective documentation pages.

<br />

For detailed information on these shared security protocols, please refer to the [Payins Security page](https://docs.dlocal.com/reference/payins-security).

<br />

***

# Signature: How does it work

## Payload signature

The signature must be calculated using the **request payload** as the data to be hashed and the merchant **secret key** as the hashing key, using the HMAC SHA256 algorithm. The resulting signature should be provided to the Payouts API in hexadecimal lowercase format.

## Signature calculation example

The following codes describe an example signature calculation.

Our GitHub repository hosts a variety of signature examples, which can be a valuable resource for understanding implementation details and for reference in your development process.

[Check out signature examples on GitHub > ](https://github.com/tam-dlocal/Starter-Code-Examples)

```java
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

public static String generateHMACSHA256Signature(String payload, String secretKey) 
        throws NoSuchAlgorithmException, InvalidKeyException {
    
    Mac mac = Mac.getInstance("HmacSHA256");
    mac.init(new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
    byte[] hashBytes = mac.doFinal(payload.getBytes(StandardCharsets.UTF_8));
    
    StringBuilder hex = new StringBuilder(hashBytes.length * 2);
    for (byte b : hashBytes) {
        hex.append(String.format("%02x", b));
    }
    return hex.toString();
}
```
```php
$secretKey = 'xxxxxxxxxxx';
$requestPayload = { … }
$signature = hash_hmac('sha256', $requestPayload, $secretKey, false)
```
```python
import hmac
import hashlib

def generate_hmac_sha256_signature(payload, secret_key):
   return hmac.new(
       secret_key.encode('utf-8'),
       payload.encode('utf-8'),
       hashlib.sha256
   ).hexdigest()
```
```ruby
require 'openssl'
require 'json'

secret_key = 'my-secret-key'
request_payload = { user_id: 123, action: 'login' }
signature = OpenSSL::HMAC.hexdigest('SHA256', secret_key, request_payload.to_json)
puts signature # Output: lowercase hex string
```
```typescript
import * as crypto from 'crypto';

const secretKey = 'xxxxxxxxxxx';
const requestPayload = { /* your object */ };
const signature = crypto
    .createHmac('sha256', secretKey)
    .update(JSON.stringify(requestPayload))
    .digest('hex');
```
```csharp C#
using System;
using System.Text;
using System.Security.Cryptography;

static string GenerateHMACSHA256Signature(string payload, string secretKey)
    {
        byte[] keyBytes = Encoding.UTF8.GetBytes(secretKey);
        byte[] payloadBytes = Encoding.UTF8.GetBytes(payload);

        using (var hmacsha256 = new HMACSHA256(keyBytes))
        {
            byte[] hashBytes = hmacsha256.ComputeHash(payloadBytes);
            return BitConverter.ToString(hashBytes).Replace("-", "").ToLower();
        }
    }
```

<br />

> Do not forget to use your Secret key for masking your signature. Read more information in the [Get your API test credentials](https://docs.dlocal.com/docs/get-api-credentials) section.

# Signature testing

We strongly suggest testing your generated signature by [using the Get Exchange Rate](https://docs.dlocal.com/reference/get-exchange-rate-payouts) call, to make sure your signature is working before moving forward with the integration