Contact API Documentation
A RESTful Contact Management API with JWT authentication. Integrate powerful address book features into any application.
Authentication
The API uses JWT Bearer tokens. Obtain a token by posting credentials to /auth/login, then include it in the Authorization header of every subsequent request.
Authorization: Bearer <your_access_token>
Access tokens expire after 1 hour. Use the /auth/refresh endpoint with your refresh token to obtain a new access token without re-authenticating.
API Endpoints
Base URL: https://api.yoursite.com/wp-json/addressbook/v1
Auth Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/login | Get access + refresh tokens |
| POST | /auth/refresh | Refresh access token |
| GET | /auth/me | Get current user info |
Contact Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /contacts | List contacts (paginated) |
| POST | /contacts | Create a new contact |
| GET | /contacts/{id} | Get a single contact |
| PUT | /contacts/{id} | Update a contact |
| DELETE | /contacts/{id} | Delete a contact |
Query Parameters (GET /contacts)
| Parameter | Type | Default | Description |
|---|---|---|---|
search | string | — | Search name, email, phone |
tag | string | — | Filter by tag |
page | integer | 1 | Page number |
per_page | integer | 20 | Results per page (max 100) |
orderby | string | name | name | email | created_at |
order | string | ASC | ASC | DESC |
Request Examples
Login
curl -X POST https://api.yoursite.com/wp-json/addressbook/v1/auth/login \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{"username":"john","password":"secret"}'
List Contacts
curl https://api.yoursite.com/wp-json/addressbook/v1/contacts?search=ali&page=1 \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "X-API-Key: YOUR_API_KEY"
Create Contact
curl -X POST https://api.yoursite.com/wp-json/addressbook/v1/contacts \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"Alice Smith","phone":"+1-555-0100","email":"[email protected]","tags":"friends,work"}'
Error Handling
All errors return JSON with success: false and an appropriate HTTP status code.
| Status | Meaning |
|---|---|
| 400 | Bad Request — missing or invalid parameters |
| 401 | Unauthorized — missing, expired, or invalid JWT |
| 403 | Forbidden — invalid API key or plan limit reached |
| 404 | Not Found — contact doesn’t exist |
| 429 | Rate Limited — slow down requests |
| 500 | Server Error — something went wrong on our end |
Rate Limiting
API calls are limited to 100 requests per minute per IP address. Login attempts are limited to 10 per minute. When rate limited you will receive a 429 response with a Retry-After header.
Ready to build?
Get your API key and start integrating the contact management system into your application.
Get API Access →