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

# Request IDs

> Track and troubleshoot API requests using unique request identifiers.

Every API request to Busha returns a unique request identifier in the response headers. Use request IDs to track specific API calls and expedite issue resolution when contacting Busha support.

## What is a Request ID?

A request ID is a unique identifier assigned to every API request. It helps both you and Busha support team pinpoint specific API calls for debugging and troubleshooting.

**Format:** `req_` followed by an alphanumeric string

**Example:** `req_JfPBXEC5rLHc`

**Validity:** Request IDs are available for 21 days after the request is made.

## How to Find the Request ID

The request ID is returned in the response headers of every API call under the `X-Request-Id` header.

### Example Request

```bash theme={null}
curl -X GET https://api.sandbox.busha.so/v1/balances \
  -H "Authorization: Bearer YOUR_SECRET_KEY" \
  -i
```

The `-i` flag includes response headers in the output.

### Example Response Headers

```
HTTP/1.1 200 OK
Date: Wed, 18 Feb 2026 13:29:10 GMT
Content-Type: application/json
X-Request-Id: req_JfPBXEC5rLHc
```

The request ID is: `req_JfPBXEC5rLHc`

## Viewing Request IDs in Code

<CodeGroup>
  ```javascript Node.js theme={null}
  const axios = require('axios');

  try {
    const response = await axios.get(
      'https://api.sandbox.busha.so/v1/balances',
      {
        headers: { 'Authorization': 'Bearer YOUR_SECRET_KEY' }
      }
    );
    
    // Get request ID from response headers
    const requestId = response.headers['x-request-id'];
    console.log('Request ID:', requestId);
    
  } catch (error) {
    // Also available in error responses
    const requestId = error.response?.headers['x-request-id'];
    console.error('Error Request ID:', requestId);
  }
  ```

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

  response = requests.get(
      'https://api.sandbox.busha.so/v1/balances',
      headers={'Authorization': 'Bearer YOUR_SECRET_KEY'}
  )

  # Get request ID from response headers
  request_id = response.headers.get('X-Request-Id')
  print(f'Request ID: {request_id}')

  # Also available in error responses
  try:
      response = requests.post(...)
  except requests.exceptions.RequestException as e:
      request_id = e.response.headers.get('X-Request-Id')
      print(f'Error Request ID: {request_id}')
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://api.sandbox.busha.so/v1/balances');
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'Authorization: Bearer YOUR_SECRET_KEY'
  ]);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HEADER, true);

  $response = curl_exec($ch);
  $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
  $headers = substr($response, 0, $header_size);

  // Extract request ID from headers
  preg_match('/X-Request-Id: (.+)/', $headers, $matches);
  $requestId = trim($matches[1]);

  echo "Request ID: " . $requestId;
  curl_close($ch);
  ?>
  ```
</CodeGroup>

## When to Use Request IDs

### Reporting API Errors

When contacting Busha support about API issues, always include the request ID. This helps our team quickly locate the specific request in our logs.

**Example support message:**

> "I'm getting a 500 error when creating a quote. Request ID: `req_JfPBXEC5rLHc`"

### Debugging Failed Requests

If an API call fails or returns unexpected results, save the request ID along with your error logs for easier debugging.

```javascript theme={null}
// Log request ID with errors
catch (error) {
  const requestId = error.response?.headers['x-request-id'];
  logger.error({
    message: 'Quote creation failed',
    requestId: requestId,
    error: error.message
  });
}
```

### Tracking Specific Operations

For critical operations, store the request ID alongside the resource ID (e.g., transfer ID, quote ID) for complete audit trails.

```javascript theme={null}
const quoteResponse = await createQuote(params);
const requestId = quoteResponse.headers['x-request-id'];

// Store both IDs
await database.save({
  quoteId: quoteResponse.data.id,      // QUO_abc123
  requestId: requestId,                 // req_xyz789
  timestamp: new Date()
});
```

<Note>
  **21-Day Retention:** Request IDs are only available for 21 days. Don't rely on them for long-term auditing.
</Note>
