---
updatedAt: 2026-11-06T18:57:00.000Z
agentTools:
  projectIndex: https://developer-docs.paga.com/llms.txt
---

# Authentication

<PagaHero eyebrow="Secure requests">
  Every request carries your credentials and a hash that proves it hasn’t been changed. How you send your credentials depends on which API you’re calling.
</PagaHero>

## Which method does my API use?

Most APIs use HTTP Basic. Only the Business API, on `mypaga.com`, uses credential headers. Both use the same keys from [Get your API keys](https://developer-docs.paga.com/docs/introduction), both need a request hash, and every API only accepts requests from [whitelisted IP addresses](https://developer-docs.paga.com/docs/ip-whitelisting).

<PagaTiles>
  <PagaTile label="All APIs except the Business API" title="HTTP Basic">

  Combine your public key and secret key into one `Authorization` header, plus the `hash` header.

  Used by Collect, Direct Debit and every other API not on `mypaga.com`.

  </PagaTile>
  <PagaTile label="Business API only" title="Credential headers">

  Send your public key and secret key as the `principal` and `credentials` headers, plus the `hash` header.

  Recognise it by its base URL: `mypaga.com`.

  </PagaTile>
</PagaTiles>

## Example requests

Both examples call Sandbox. Swap in the Live base URL when you go live.

```shell HTTP Basic (Collect API)
curl -X POST https://beta-collect.paga.com/paymentRequest \
  -H "Content-Type: application/json" \
  -u "YOUR_PUBLIC_KEY:YOUR_SECRET_KEY" \
  -H "hash: YOUR_REQUEST_HASH" \
  -d '{"referenceNumber": "REF-0001", "amount": "5000"}'
```
```shell Credential headers (Business API)
curl -X POST https://beta.mypaga.com/paga-webservices/business-rest/secured/accountBalance \
  -H "Content-Type: application/json" \
  -H "principal: YOUR_PUBLIC_KEY" \
  -H "credentials: YOUR_SECRET_KEY" \
  -H "hash: YOUR_REQUEST_HASH" \
  -d '{"referenceNumber": "REF-0001"}'
```

In the HTTP Basic example, `-u` sends `Authorization: Basic base64(publicKey:secretKey)` for you.

## Generate the request hash

Every request needs a `hash` header: a SHA-512 hash of specific request values, in a set order, followed by your hash key. Your hash key itself is never sent.

<Steps>
  <Step title="Find the hash values for the operation">

  Each API page lists them, and the table below covers the common ones.

  </Step>
  <Step title="Join the values in order, then add your hash key">

  Use the exact order listed, with no spaces or separators, and put your hash key last.

  </Step>
  <Step title="Hash with SHA-512">

  Convert the result to a hexadecimal string.

  </Step>
  <Step title="Send it in the hash header">

  Generate a new hash for every request.

  </Step>
</Steps>

**Example: Check status**, where the values are `referenceNumber + hashKey`:

```javascript Node.js
const crypto = require("crypto");

const hashKey = process.env.PAGA_HASH_KEY;
const referenceNumber = "REF-0001";

const hash = crypto
  .createHash("sha512")
  .update(referenceNumber + hashKey)
  .digest("hex");
```
```python Python
import hashlib, os

hash_key = os.environ["PAGA_HASH_KEY"]
reference_number = "REF-0001"

hash_value = hashlib.sha512(
    (reference_number + hash_key).encode("utf-8")
).hexdigest()
```
```php PHP
$hashKey = getenv("PAGA_HASH_KEY");
$referenceNumber = "REF-0001";

$hash = hash("sha512", $referenceNumber . $hashKey);
```
```java Java
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.HexFormat;

String hashKey = System.getenv("PAGA_HASH_KEY");
String referenceNumber = "REF-0001";

MessageDigest md = MessageDigest.getInstance("SHA-512");
byte[] digest = md.digest((referenceNumber + hashKey).getBytes(StandardCharsets.UTF_8));
String hash = HexFormat.of().formatHex(digest); // Java 17+
```

### Hash values for common operations

| Operation            | API          | Values, in order                                                                          |
| -------------------- | ------------ | ----------------------------------------------------------------------------------------- |
| Payment request      | Collect      | `referenceNumber + amount + currency + payer.phoneNumber + payer.email + hashKey`         |
| Check status         | Collect      | `referenceNumber + hashKey`                                                               |
| Charge debit mandate | Direct Debit | `referenceNumber + amount + accountReference + hashKey`                                   |
| Account balance      | Business     | `referenceNumber + hashKey`                                                               |
| Deposit to bank      | Business     | `referenceNumber + amount + destinationBankUUID + destinationBankAccountNumber + hashKey` |

Every other operation lists its hash values on its own API page.

## Base URLs

| API                      | Method             | Sandbox                 | Live               |
| ------------------------ | ------------------ | ----------------------- | ------------------ |
| Collect and Direct Debit | HTTP Basic         | `beta-collect.paga.com` | `collect.paga.com` |
| Business API             | Credential headers | `beta.mypaga.com`       | `www.mypaga.com`   |

## If a request is rejected

<PagaTiles>
  <PagaTile title="Keys and URL don’t match">

  Sandbox keys only work with Sandbox URLs, and Live keys with Live URLs.

  </PagaTile>
  <PagaTile title="Hash values out of order">

  Use exactly the values and order listed for that operation, with no separators.

  </PagaTile>
  <PagaTile title="IP address not whitelisted">

  API calls only work from addresses you’ve added in [IP whitelisting](https://developer-docs.paga.com/docs/ip-whitelisting).

  </PagaTile>
  <PagaTile title="Account not approved yet">

  Keys work once your account is approved. See [Get started](https://developer-docs.paga.com/docs/get-started).

  </PagaTile>
</PagaTiles>

<HelpBanner />