> ## Documentation Index
> Fetch the complete documentation index at: https://docs.splashpay.co.tz/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Securely authenticate requests to SplashPay APIs.

# Authentication

All SplashPay API requests require authentication using API credentials.

***

## API Credentials

Generate API credentials from:

**Merchant Portal → Developers → API Keys**

> [tab] Test Keys
>
> Used in Sandbox environment.
>
> ```http theme={null}
> X-API-KEY: pk_test_xxxxxxxxxxxxx
> X-API-SECRET: sk_test_xxxxxxxxxxxxx
> ```

> [tab] Live Keys
>
> Used in Production environment.
>
> ```http theme={null}
> X-API-KEY: pk_live_xxxxxxxxxxxxx
> X-API-SECRET: sk_live_xxxxxxxxxxxxx
> ```

***

## Required Headers

```http theme={null}
X-API-KEY: pk_live_xxxxxxxxxxxxx
X-API-SECRET: sk_live_xxxxxxxxxxxxx
Idempotency-Key: Unique-Request-ID
Content-Type: application/json
Accept: application/json
```

***

## Example Request

> [tab] cURL
>
> ```bash theme={null}
> curl --request GET \
>   --url https://api.splashpay.co.tz/api/v1/payments/mobile-money \
>   --header "X-API-KEY: pk_live_xxxxxxxxx" \
>   --header "X-API-SECRET: sk_live_xxxxxxxxx" \
>   --header "Idempotency-Key: Unique-Request-ID"
> ```

> [tab] Laravel
>
> ```php theme={null}
> $response = Http::withHeaders([
>     'X-API-KEY' => env('SPLASHPAY_KEY'),
>     'X-API-SECRET' => env('SPLASHPAY_SECRET'),
>     'Idempotency-Key' => 'Unique-Request-ID',
> ])->get(
>     'https://api.splashpay.co.tz/api/v1/payments/mobile-money'
> );
> ```

> [tab] Node.js
>
> ```javascript theme={null}
> const response = await fetch(
>   'https://api.splashpay.co.tz/api/v1/payments/mobile-money',
>   {
>     headers: {
>       'X-API-KEY': process.env.SPLASHPAY_KEY,
>       'X-API-SECRET': process.env.SPLASHPAY_SECRET,
>       'Idempotency-Key': 'Unique-Request-ID',
>     },
>   }
> );
> ```

> [tab] Python
>
> ```python theme={null}
> import requests
>
> response = requests.get(
>     'https://api.splashpay.co.tz/api/v1/payments/mobile-money',
>     headers={
>         'X-API-KEY': os.getenv('SPLASHPAY_KEY'),
>         'X-API-SECRET': os.getenv('SPLASHPAY_SECRET'),
>         'Idempotency-Key': 'Unique-Request-ID',
>     }
> )
> ```

> [tab] Dart
>
> ```dart Dart theme={null}
> import 'dart:convert';
> import 'package:http/http.dart' as http;
> import 'package:uuid/uuid.dart';
>
> Future<void> initiateMobileMoneyPayment() async {
>  final response = await http.post(
>    Uri.parse(
>      'https://api.splashpay.co.tz/api/v1/payments/mobile-money',
>    ),
>    headers: {
>      'Content-Type': 'application/json',
>      'X-API-KEY': const String.fromEnvironment('SPLASHPAY_KEY'),
>      'X-API-SECRET': const String.fromEnvironment('SPLASHPAY_SECRET'),
>      'Idempotency-Key': const Uuid().v4(),
>    },
>  );
> }
> ```

***

## Authentication Errors

| Status | Description |
| - | - |
| 401 | Invalid API credentials |
| 403 | Access denied |
| 429 | Too many requests |

***

> [!WARNING]
>
> Never expose your API Secret in frontend applications, mobile apps, or public repositories.

***

## Best Practices

> [!TIP]
>
> Store API credentials in environment variables.

> [!TIP]
>
> Rotate API secrets regularly.

> [!TIP]
>
> Use Sandbox credentials during development.

> [!TIP]
>
> Keep API secrets private.

***

## Next Steps

> [card] [Initiate Collection](https://docs.splashpay.co.tz/collections/initiate)
>
> Create payment requests and collect payments.

> [card] [Webhooks](https://docs.splashpay.co.tz/webhooks/overview)
>
> Receive transaction updates automatically.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.