Authentication

The MyOpcs API uses API keys to authenticate requests. Manage your API keys in the Dashboard Settings.

Getting your API Key

Follow these steps to obtain your API key:

1

Sign in to your MyOpcs account

3

Scroll to the API Keys section

4

Click "Create API Key" to generate a new key

5

Copy and securely store your API key

Keep your API key secure

Never share your API key or commit it to version control. Treat it like a password. If your key is compromised, revoke it immediately from your dashboard.

Using your API Key

Include your API key in the Authorization header as a Bearer token:

Bash
curl https://api.myopcs.com/api/v1/products \
  -H "Authorization: Bearer YOUR_API_KEY"

API Key Format

All API keys start with the myopcs_ prefix:

Format
myopcs_<32-character-random-string>

Error Handling

If your API key is missing or invalid, you'll receive a 401 Unauthorized response:

{}JSON
{
  "error": {
    "type": "unauthorized",
    "message": "Invalid API key provided"
  }
}

Best Practices

Use environment variables

Store API keys in env vars, never hardcode them

Rotate keys periodically

Enhance security by refreshing keys regularly

Separate dev & production

Use different keys for development and production

Monitor API usage

Track usage patterns in your dashboard

Revoke compromised keys

Immediately revoke if a key is exposed

Security tip

Consider using a secrets manager (like AWS Secrets Manager, HashiCorp Vault, or Doppler) to manage your API keys in production environments.