Getting Started
This guide walks you through the basic steps for authenticating and interacting with the third-party API.
For a complete working example, check out our example repository which demonstrates:
- OAuth2-based authentication flow with access and refresh tokens
- Automatic token refresh when expired
- Persistent token storage
- Example API calls to fetch entities
1a. Obtain Access Token
Before making any requests to the API, you must authenticate using your username and password to receive an access token and refresh token.
curl -X POST https://api.newprojectmedia.com/customer-api/auth/login \
-H "Content-Type: application/json" \
-d '{
"username": "<your-username>",
"password": "<your-password>"
}'
# Response body
{
"accessToken": "<new-access-token>",
"refreshToken": "<new-refresh-token>",
"expiresIn": 3600,
"tokenType": "Bearer"
}
💡 Store both tokens securely. The access token will be used in all subsequent API requests.
- Access tokens expire after 1 hour
- Refresh tokens expire after 30 days
1b. Handle Token Expiration
When an access token expires (after 1 hour), use the refresh token to request a new access token. Refresh tokens remain valid for 30 days from their issue date.
curl -X POST https://api.newprojectmedia.com/customer-api/auth/refresh \
-H "Content-Type: application/json" \
-d '{
"refreshToken": "<your-refresh-token>",
}'
# Response body
{
"accessToken": "<new-access-token>"
}
2. Call a protected API endpoint
Here's an example of how to fetch multiple queue items, using the access token as a Bearer token:
curl -X POST https://api.newprojectmedia.com/customer-api/entities/queues \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your-access-token>" \
-d '{
"queryType": "getItemsQuery",
"queryParams": {
"page": 1,
"pageSize": 10,
"sortBy": {
"field": "queueDate",
"direction": "desc"
},
"filters": [
{
"field": "status",
"value": "Operational",
"operator": "eq"
}
],
"source": ["projectName", "totalMw", "status"]
}
}'