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

# Sandbox

> Test your integration without real payments

The Safefy API uses the same base URL for both Sandbox and Production environments. The active environment is determined automatically based on the type of credentials used.

| Environment    | Credentials                               | Behavior                                  |
| -------------- | ----------------------------------------- | ----------------------------------------- |
| **Sandbox**    | `pk_sandbox_...` / `sk_sandbox_...`       | Simulated payments and fictitious balance |
| **Production** | `pk_production_...` / `sk_production_...` | Real PIX transactions                     |

**API URL:** `https://api-payment.safefypay.com.br`

***

## Creating credentials

1. Access the [Safefy panel](https://app.safefypay.com.br)
2. Go to **Settings  API Credentials**
3. Choose the environment (**Sandbox** or **Production**) and click **Generate**
4. Copy the `clientSecret` immediately  it will not be shown again

***

## Simulating transactions

In Sandbox, you can simulate status changes using the simulate endpoint:

```bash theme={null}
curl -X POST https://api-payment.safefypay.com.br/v1/transactions/{id}/simulate \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{"action": "pay"}'
```

| Action   | From status | To status   |
| -------- | ----------- | ----------- |
| `pay`    | `Pending`   | `Completed` |
| `expire` | `Pending`   | `Expired`   |
| `fail`   | `Pending`   | `Failed`    |
| `refund` | `Completed` | `Refunded`  |

<Warning>
  Transaction simulation only works with Sandbox credentials. Using Production credentials will return an error.
</Warning>

***

## Complete test flow

1. **Create a transaction**  `POST /v1/transactions` with `method: "pix"` and an `amount`
2. **Display the QR Code**  use the `pix.copyAndPaste` field to render a QR Code in your app
3. **Simulate payment**  call `POST /v1/transactions/{id}/simulate` with `action: "pay"`
4. **Receive the webhook**  your `callbackUrl` will receive a `payment.completed` event
5. **Validate**  confirm the transaction status is `Completed`

***

## Simulating cashouts

```bash theme={null}
curl -X POST https://api-payment.safefypay.com.br/v1/cashouts/{id}/simulate \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{"action": 1}'
```

| Action | To status   |
| ------ | ----------- |
| `1`    | `Completed` |
| `2`    | `Failed`    |
| `3`    | `Rejected`  |
