SimplyPNG/Documentation

Authentication

Authenticate your API requests using API keys.

API Keys

SimplyPNG uses API keys to authenticate requests. You can create and manage your API keys from the developer console.

Key Types

Test Keys
Prefix: sp_test_
  • Use for development and testing
  • Same functionality as live keys
  • Charges credits normally
Live Keys
Prefix: sp_live_
  • Use for production applications
  • Full access to all features
  • Charges credits normally

Using Your API Key

Include your API key in every request using one of three methods:

Method 1: Authorization Header (Recommended)

curl -X POST https://api.simplypng.app/api/v1/jobs \
  -H "Authorization: Bearer sp_test_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "https://example.com/photo.jpg"}'

Method 2: X-API-Key Header

curl -X POST https://api.simplypng.app/api/v1/jobs \
  -H "X-API-Key: sp_test_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "https://example.com/photo.jpg"}'

Method 3: Query Parameter

curl "https://api.simplypng.app/api/v1/credits?api_key=sp_test_YOUR_API_KEY"

Note: Query parameter auth is convenient for quick testing (e.g., checking credit balance in a browser). For production use, prefer header-based auth to avoid exposing keys in URLs, logs, and browser history.

Security Best Practices

Keep keys secret

Never expose API keys in client-side code, public repositories, or logs. Use environment variables to store keys securely.

Use separate keys per environment

Create different keys for development, staging, and production. This makes it easier to rotate keys if one is compromised.

Revoke unused keys

Regularly review your API keys and revoke any that are no longer needed. Revocation is immediate and irreversible.

Never share your API key

If you believe a key has been compromised, revoke it immediately and create a new one. SimplyPNG support will never ask for your API key.

Error Responses

If authentication fails, you'll receive a 401 error response:

{
  "error": {
    "type": "authentication_error",
    "code": "INVALID_API_KEY",
    "message": "Invalid or expired API key"
  },
  "request_id": "req_1703260800000_a1b2c3d4e5f6"
}

Common Error Codes

CodeDescription
MISSING_API_KEYNo API key provided in the request
INVALID_API_KEYAPI key format is invalid or key not found
REVOKED_API_KEYAPI key has been revoked
EXPIRED_API_KEYAPI key has expired