Authentication
FreshPurpose
Configure and use Creatify API authentication headers for all API requests.
Prerequisites
- Active Creatify account with API access enabled
- API ID and API Key from your Creatify dashboard
Procedure
Step 1: Obtain Credentials
- Log in to creatify.ai
- Go to Settings then API
- Your API ID and API Key are displayed on this page
- Copy both values
Step 2: Store Credentials Securely
Store credentials as environment variables. Never hardcode them in source code.
Bash / Linux / macOS:
bash
export CREATIFY_API_ID="your-api-id-here"
export CREATIFY_API_KEY="your-api-key-here"Windows PowerShell:
powershell
$env:CREATIFY_API_ID = "your-api-id-here"
$env:CREATIFY_API_KEY = "your-api-key-here"dotenv file (.env):
CREATIFY_API_ID=your-api-id-here
CREATIFY_API_KEY=your-api-key-hereWARNING
Never commit .env files to version control. Add .env to your .gitignore.
Step 3: Include Auth Headers on Every Request
Every API request must include both headers:
bash
curl --request GET \
--url https://api.creatify.ai/api/workspace/remaining_credits/ \
--header "X-API-ID: $CREATIFY_API_ID" \
--header "X-API-KEY: $CREATIFY_API_KEY"Step 4: Language-Specific Examples
Python (requests):
python
import os
import requests
headers = {
"X-API-ID": os.environ["CREATIFY_API_ID"],
"X-API-KEY": os.environ["CREATIFY_API_KEY"],
"Content-Type": "application/json"
}
response = requests.get(
"https://api.creatify.ai/api/workspace/remaining_credits/",
headers=headers
)
print(response.json())JavaScript (fetch):
javascript
const headers = {
"X-API-ID": process.env.CREATIFY_API_ID,
"X-API-KEY": process.env.CREATIFY_API_KEY,
"Content-Type": "application/json"
};
const response = await fetch(
"https://api.creatify.ai/api/workspace/remaining_credits/",
{ headers }
);
const data = await response.json();
console.log(data);Node.js (axios):
javascript
const axios = require("axios");
const client = axios.create({
baseURL: "https://api.creatify.ai/api",
headers: {
"X-API-ID": process.env.CREATIFY_API_ID,
"X-API-KEY": process.env.CREATIFY_API_KEY,
"Content-Type": "application/json"
}
});
const { data } = await client.get("/workspace/remaining_credits/");
console.log(data);Auth Header Reference
| Header | Required | Description |
|---|---|---|
X-API-ID | Yes | Your API identifier from the Creatify dashboard |
X-API-KEY | Yes | Your API secret key from the Creatify dashboard |
Content-Type | For POST/PUT/PATCH | Always application/json for JSON request bodies |
Error Responses
| Status | Meaning | Action |
|---|---|---|
| 401 Unauthorized | Missing or invalid credentials | Verify API ID and API Key are correct |
| 403 Forbidden | API access not enabled on account | Contact Creatify support to enable API access |
| 429 Too Many Requests | Rate limit exceeded | Implement exponential backoff and retry |
Verification Checklist
- [ ] API ID and API Key copied from dashboard
- [ ] Credentials stored in environment variables (not hardcoded)
- [ ]
.envfile added to.gitignore - [ ] Test request to
/api/workspace/remaining_credits/returns 200 - [ ] No credentials visible in client-side code or version control
Security Best Practices
TIP
- Rotate keys periodically -- Regenerate your API key from the dashboard on a regular schedule
- Use server-side only -- Never expose credentials in browser JavaScript
- Separate environments -- Use different keys for development and production
- Monitor usage -- Check remaining credits regularly to detect unauthorized use
See Also
- Quickstart -- First API call walkthrough
- Billing and Credits -- Credit system details
- Troubleshooting -- Common auth errors