API: integrate link creation & analytics
Automate link creation, rule configuration, and analytics retrieval. Use API keys for authentication and permission-scoped access.
This is a safe “public” reference. Map endpoints/fields to your actual backend.
Authentication (API key)
Generate API keys in the dashboard and display them only once. Send the key via headers.
Authorization: Bearer YOUR_API_KEY Accept: application/json
- Never hardcode API keys in the frontend.
- Rotate keys periodically and revoke on suspicion.
- Scope permissions by user/project if available.
Base URL & versioning
Version your API to avoid breaking integrations when you ship changes.
https://1linkad.com/api/v1
- Return consistent JSON: ok/data/error.
- Standardize error codes/messages for easier debugging.
Rate limits & common errors
Set rate limits to protect your system and prevent abuse.
- 429429 Too Many Requests: over limit.
- 401401 Unauthorized: missing/invalid API key.
- 403403 Forbidden: insufficient permissions.
- 422422 Validation error: invalid payload.
- 500500: internal error (include trace_id).
- Expose X-RateLimit-* headers for clients.
- Always include trace_id in error responses for fast support.
Endpoint list (reference)
These endpoints are reference examples—map them to your actual backend.
cURL examples
Reference examples for creating a link and fetching analytics.
curl -X POST "https://1linkad.com/api/v1/links" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"domain": "go.example.com",
"slug": "summer-sale",
"target_url": "https://example.com/landing",
"tracking": true,
"redirect_code": 302,
"rules": [
{"if": {"country": ["VN"], "device": ["mobile"]}, "to": "https://example.com/vn-m"},
{"if": {"country": ["VN"]}, "to": "https://example.com/vn"}
],
"fallback_url": "https://example.com/default"
}'
curl -X GET "https://1linkad.com/api/v1/analytics/links/123?from=2026-02-01&to=2026-02-11" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Accept: application/json"
- Always validate target_url and protect against SSRF in backend.
- If rules are complex, provide a dry-run endpoint to test matching.
Webhook/Postback (optional)
If you need to send events back to your system (conversion/click), use webhook/postback.
- Sign payloads with HMAC to authenticate events.
- Retry with backoff on 5xx responses.
- Allow users to enable/disable per project.
Integration security checklist
Minimum security checklist for safe APIs:
- Rate limit by API key + IP.
- Audit logs: who created/updated/deleted links and when.
- URL validation (SSRF protection), block dangerous schemes (file://, gopher://…).
- CORS only when truly needed.
- Return trace_id for every request for debugging.
FAQ
Want to integrate via API?
Generate an API key and start creating links/analytics via the API.