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

# Getting Your API Key

> Generate and manage API keys to access NativeBridge REST API

# Getting Your API Key

API keys allow you to programmatically interact with NativeBridge, enabling you to upload apps, generate magic links, and automate your testing workflows.

<Info>
  API keys are tied to your organization and have the same permissions as your user account. Keep them secure and never share them publicly.
</Info>

## Generate Your First API Key

Follow these simple steps to create your API key:

<Steps>
  <Step title="Navigate to Dashboard">
    Log in to your NativeBridge account and go to your [Dashboard](https://nativebridge.io/dashboard)
  </Step>

  <Step title="Access API Keys Section">
    Click on **"API Keys"** in the sidebar navigation or go directly to [API Keys](https://nativebridge.io/settings/api-keys)
  </Step>

  <Step title="Create New API Key">
    Click the **"Generate New API Key"** button
  </Step>

  <Step title="Name Your Key">
    Give your API key a descriptive name (e.g., "GitHub Actions", "Development", "Production")
  </Step>

  <Step title="Copy and Save">
    Copy your API key immediately - you won't be able to see it again once you leave the page
  </Step>
</Steps>

<Warning>
  **Important:** Your API key will only be shown once. Make sure to copy and store it securely before navigating away from the page.
</Warning>

## Visual Guide

<Frame />

The API Keys section in your dashboard shows:

* List of all active API keys
* When each key was created
* Last used timestamp
* Options to revoke keys

## Using Your API Key

Once you have your API key, you can use it in your API requests:

### In HTTP Headers

```bash theme={null}
curl -X POST https://api.nativebridge.dev/v1/apps/upload \
  -H "Authorization: Bearer YOUR_API_KEY_HERE" \
  -F "file=@app.apk" \
  -F "platform=android"
```

### In Environment Variables

Store your API key as an environment variable for security:

```bash theme={null}
# .env file
NATIVEBRIDGE_API_KEY=your_api_key_here
```

```javascript theme={null}
// Node.js
const apiKey = process.env.NATIVEBRIDGE_API_KEY;

const response = await fetch('https://api.nativebridge.dev/v1/apps/upload', {
  headers: {
    'Authorization': `Bearer ${apiKey}`
  }
});
```

### In CI/CD Pipelines

#### GitHub Actions

1. Go to your repository Settings → Secrets → Actions
2. Add a new secret named `NATIVEBRIDGE_API_KEY`
3. Use in your workflow:

```yaml theme={null}
- name: Upload to NativeBridge
  run: |
    curl -X POST https://api.nativebridge.dev/v1/apps/upload \
      -H "Authorization: Bearer ${{ secrets.NATIVEBRIDGE_API_KEY }}" \
      -F "file=@app.apk"
```

#### GitLab CI

1. Go to Project Settings → CI/CD → Variables
2. Add a variable named `NATIVEBRIDGE_API_KEY`
3. Use in your pipeline:

```yaml theme={null}
upload_app:
  script:
    - curl -X POST https://api.nativebridge.dev/v1/apps/upload \
        -H "Authorization: Bearer $NATIVEBRIDGE_API_KEY" \
        -F "file=@app.apk"
```

## Managing API Keys

### View All Keys

Your [API Keys dashboard](https://nativebridge.io/settings/api-keys) displays:

| Column    | Description                           |
| --------- | ------------------------------------- |
| Name      | The descriptive name you gave the key |
| Created   | When the key was generated            |
| Last Used | Most recent API call using this key   |
| Actions   | Revoke or regenerate the key          |

### Revoke a Key

To revoke an API key:

1. Go to [API Keys](https://nativebridge.io/settings/api-keys)
2. Find the key you want to revoke
3. Click the **"Revoke"** button
4. Confirm the action

<Warning>
  Revoking a key immediately invalidates it. Any services using this key will lose access.
</Warning>

### Regenerate a Key

If you suspect a key has been compromised:

1. Revoke the compromised key immediately
2. Generate a new key with the same name
3. Update all services with the new key

## Best Practices

<Cards>
  <Card title="Use Descriptive Names" icon="tag">
    Name keys based on their purpose: "Production API", "GitHub Actions", "Local Development"
  </Card>

  <Card title="Rotate Regularly" icon="refresh">
    Rotate API keys every 90 days for enhanced security
  </Card>

  <Card title="Limit Scope" icon="shield">
    Create separate keys for different environments (dev, staging, production)
  </Card>

  <Card title="Never Commit Keys" icon="lock">
    Never commit API keys to version control - use environment variables instead
  </Card>
</Cards>

## Security Guidelines

### DO ✅

* Store keys in environment variables or secrets management systems
* Use different keys for different environments
* Revoke unused or compromised keys immediately
* Monitor key usage in your dashboard
* Use HTTPS for all API requests

### DON'T ❌

* Share keys in emails or chat messages
* Commit keys to git repositories
* Use the same key across multiple projects
* Expose keys in client-side code
* Log or print keys in console output

## Rate Limits by Plan

API keys inherit the rate limits of your subscription plan:

| Plan    | API Calls/Hour | Concurrent Requests |
| ------- | -------------- | ------------------- |
| Free    | 60             | 1                   |
| Starter | 300            | 3                   |
| Growth  | 1000           | 10                  |
| Custom  | Unlimited      | Unlimited           |

<Info>
  Need higher limits? [Contact us](mailto:contact@autoflowapp.com) to discuss custom plans.
</Info>

## Troubleshooting

<AccordionGroup>
  <Accordion title="API Key not working">
    * Ensure you're including "Bearer " before the key in the Authorization header
    * Check that the key hasn't been revoked
    * Verify you're using the correct API endpoint
    * Make sure there are no extra spaces or characters
  </Accordion>

  <Accordion title="Can't see API Keys section">
    * Verify you have the necessary permissions in your organization
    * Check if your plan includes API access
    * Contact your organization admin for access
  </Accordion>

  <Accordion title="Forgot to copy key">
    * Once created, keys cannot be viewed again for security
    * You'll need to revoke the old key and create a new one
    * Make sure to update all services with the new key
  </Accordion>

  <Accordion title="Rate limit exceeded">
    * Check your current plan's limits in the dashboard
    * Consider upgrading to a higher plan
    * Implement request caching and batching
  </Accordion>
</AccordionGroup>

## Example: Your First API Call

Once you have your API key, try this simple test:

```bash theme={null}
# Test your API key
curl -X GET https://api.nativebridge.dev/v1/account \
  -H "Authorization: Bearer YOUR_API_KEY_HERE"

# Expected response:
{
  "organization": "Your Organization",
  "plan": "starter",
  "api_calls_remaining": 298
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="API Reference" icon="book" href="/api-reference">
    Explore all available API endpoints
  </Card>

  <Card title="Upload Your First App" icon="upload" href="/platform/app-management/uploading-apps/uploading-apps">
    Start uploading apps via API
  </Card>

  <Card title="CI/CD Integration" icon="code-branch" href="/api-reference#cicd-integration">
    Automate with GitHub Actions & GitLab
  </Card>

  <Card title="Postman Collection" icon="external-link" href="https://documenter.getpostman.com/view/41713518/2sAYkGLf4d">
    Interactive API documentation
  </Card>
</CardGroup>
