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

# Authentication

> Create your API key, send credentials, and select scopes.

## Overview

The DoglyTdc Pay API uses **API keys** with a `client_id` and `client_secret`. There is no token exchange: you send both parts with every request, always over HTTPS.

![Screenshot: API keys in DoglyTdc Pay](https://mintcdn.com/dogly-tdc/qOnot79kPtISSKbW/images/pay/pay-api.png?fit=max\&auto=format\&n=qOnot79kPtISSKbW\&q=85\&s=3002ebf0377906f83f1b8dbbd6f19284)

API keys in DoglyTdc Pay

## Authentication flow

```mermaid theme={null}
sequenceDiagram
  participant App as Your application
  participant Pay as DoglyTdc Pay API
  App->>Pay: GET /products (Authorization: Basic …)
  Pay->>Pay: checks key, secret, and scopes
  Pay-->>App: 200 { data: [...] }
```

## 1 - Creating the API key

**1. Open DoglyTdc Pay**

Go to **DoglyTdc Pay › Integrations › DoglyTdc Pay API**.

**2. Create the key**

Provide a name (e.g., "My store") and select the scopes.

**3. Copy the secret**

The `client_secret` is displayed **only once**. Store it in a secrets manager.

> [!WARNING]
>
> DoglyTdc only stores a hash of the secret. If lost, revoke the key and create a new one.

## 2 - Sending credentials

Three accepted formats (use one):

```bash Basic (recommended) theme={null}
curl https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-pay/v1/products \
  -u "dpk_YOUR_CLIENT_ID:YOUR_CLIENT_SECRET"
```

```bash Bearer theme={null}
curl https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-pay/v1/products \
  -H "Authorization: Bearer dpk_YOUR_CLIENT_ID:YOUR_CLIENT_SECRET"
```

```bash Separate headers theme={null}
curl https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-pay/v1/products \
  -H "X-Client-Id: dpk_YOUR_CLIENT_ID" \
  -H "X-Client-Secret: YOUR_CLIENT_SECRET"
```

## 3 - Access scopes

Each endpoint requires **all** scopes listed for it. Read operations require `read` + the resource; write operations require `write` + the resource.

| Scope | Description |
| - | - |
| `read` | Read account data |
| `write` | Create and modify data (along with the resource scope) |
| `products` | Products |
| `offers` | Offers and pricing |
| `orders` | Orders and refunds |
| `subscriptions` | Subscriptions |
| `webhooks` | List and create webhooks |
| `payments` | Payment links |
| `withdrawals_read` | View balance and payouts |
| `withdrawals_request` | Request payout (always requires in-app confirmation) |

Without the required scope, the response is `403 insufficient_scope` indicating which scopes are missing.

## Security

* Use the key **only on the server**. Never expose it in the browser, mobile app, or code repository.
* One key per integration, with the minimum required scopes.
* Immediately revoke any exposed key under **Integrations › DoglyTdc Pay API**.
* Refunds and payment links always require your approval within DoglyTdc Pay.

## Client examples

```javascript Node.js theme={null}
const auth = Buffer.from(`${process.env.DPAY_CLIENT_ID}:${process.env.DPAY_CLIENT_SECRET}`).toString("base64");
const res = await fetch("https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-pay/v1/orders", { headers: { Authorization: `Basic ${auth}` } });
const { data } = await res.json();
```

```python Python theme={null}
import os, requests
r = requests.get("https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-pay/v1/orders", auth=(os.environ["DPAY_CLIENT_ID"], os.environ["DPAY_CLIENT_SECRET"]))
print(r.json()["data"])
```

```php PHP theme={null}
$ch = curl_init("https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-pay/v1/orders");
curl_setopt($ch, CURLOPT_USERPWD, getenv("DPAY_CLIENT_ID") . ":" . getenv("DPAY_CLIENT_SECRET"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$orders = json_decode(curl_exec($ch), true)["data"];
```


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