> ## Documentation Index
> Fetch the complete documentation index at: https://run-deliverys.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Base URL and environments

> Production and staging hosts, and how test vs live API keys map to environments.

export const API_PRODUCTION_URL = "https://api.rundeliverys.com/api/v2";

export const API_STAGING_URL = "https://staging.rundeliverys.com/api/v2";

All API requests are made relative to `/api/v2`.

All examples in these docs use **staging**. Set your env vars once, then every `$RUN_BASE_URL` call hits staging.

| Environment | Base URL |
| - | - |
| Staging | <code>{API_STAGING_URL}</code> |
| Production | <code>{API_PRODUCTION_URL}</code> |

## Example keys

| Prefix | Environment | Host |
| - | - | - |
| `run_test_` | Staging | `staging.rundeliverys.com` |
| `run_live_` | Production | `api.rundeliverys.com` |

```bash theme={null}
export RUN_BASE_URL={API_STAGING_URL}
export RUN_API_KEY=run_test_fce859d98c4f0e2b1e644d5a46e2fb9fb45bde58b36a0wfj
```

The server only accepts keys that match its current environment. A live key against staging returns `401`.

When you go live, switch both values together:

```bash theme={null}
export RUN_BASE_URL={API_PRODUCTION_URL}
export RUN_API_KEY=run_live_fce859d98c4f0e2b1e644d5a46e2fb9fb45bde58b36a0wfj
```

## Making requests

Send JSON bodies with `Content-Type: application/json`. Always include your Bearer token.

<CodeGroup>
  ```bash cURL theme={null}
  curl "$RUN_BASE_URL/business/orders?limit=5" \
    -H "Authorization: Bearer $RUN_API_KEY" \
    -H "Content-Type: application/json"
  ```

  ```javascript Node.js theme={null}
  const res = await fetch(`${process.env.RUN_BASE_URL}/business/order/cost`, {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.RUN_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      pickup_address: '12 Admiralty Way, Lekki, Lagos',
      dropoff_address: '15 Broad Street, Lagos Island, Lagos',
      weight: 2,
    }),
  });
  const data = await res.json();
  ```

  ```python Python theme={null}
  import os
  import requests

  res = requests.post(
      f"{os.environ['RUN_BASE_URL']}/business/order/cost",
      headers={
          "Authorization": f"Bearer {os.environ['RUN_API_KEY']}",
          "Content-Type": "application/json",
      },
      json={
          "pickup_address": "12 Admiralty Way, Lekki, Lagos",
          "dropoff_address": "15 Broad Street, Lagos Island, Lagos",
          "weight": 2,
      },
  )
  data = res.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init(getenv('RUN_BASE_URL') . '/business/order/cost');
  curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
      'Authorization: Bearer ' . getenv('RUN_API_KEY'),
      'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
      'pickup_address' => '12 Admiralty Way, Lekki, Lagos',
      'dropoff_address' => '15 Broad Street, Lagos Island, Lagos',
      'weight' => 2,
    ]),
  ]);
  $data = json_decode(curl_exec($ch), true);
  curl_close($ch);
  ```

  ```go Go theme={null}
  package main

  import (
    "bytes"
    "fmt"
    "io"
    "net/http"
    "os"
  )

  func main() {
    body := []byte(`{
      "pickup_address": "12 Admiralty Way, Lekki, Lagos",
      "dropoff_address": "15 Broad Street, Lagos Island, Lagos",
      "weight": 2
    }`)
    req, _ := http.NewRequest(
      "POST",
      os.Getenv("RUN_BASE_URL")+"/business/order/cost",
      bytes.NewReader(body),
    )
    req.Header.Set("Authorization", "Bearer "+os.Getenv("RUN_API_KEY"))
    req.Header.Set("Content-Type", "application/json")
    res, err := http.DefaultClient.Do(req)
    if err != nil {
      panic(err)
    }
    defer res.Body.Close()
    out, _ := io.ReadAll(res.Body)
    fmt.Println(string(out))
  }
  ```
</CodeGroup>

<Tip>
  Store `RUN_API_KEY` in environment variables on your server — never hard-code it in source.
</Tip>


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