All requests to the Naxai API must be authenticated through the Authorization header. The Naxai API offers the following authentication methods:
- OAuth 2.0
- Credentials in Header (not recommended)
Select your preferred method to suit your current tech stack and security requirement level. Many of these methods are vulnerable to man-in-the-middle attacks, so combining them with other security mechanisms, such as an encrypted connection or SSL is recommended.
API Credentials
You can generate additional client credentials in your account settings (Integrations -> API Credentials).
Follow our guide for more information.
OAuth 2.0
This type of authentication is the most secure option and is almost industry standard. You'll use an access token you get from a separate endpoint.
Here are some key facts about this method:
The access token returned in response will expire within the time limit provided in seconds in the same response.
A new token has to be created once the token expires - There is no automatic token retrieval
For more details, see the official OAuth 2.0 specification.
How to use OAuth 2.0
Make a call to get the access token and the expiration time from a separate endpoint.
Include "Bearer " and the token in the Authorization header for all subsequent calls until the token expires.
Authorization: Bearer eyJhcGciOiJSUzI1NiIsInR5...
HTTP Request
Obtain OAuth2 token
curl --location 'https://auth.naxai.com/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=DkMLm4ghpnx7wVoqiKYZSBTE1Zr16EdE' \
--data-urlencode 'client_secret=YNjm5x5lp9qymcJmL1AdfAia2YwUTN4ARSVC1jSsi6sp4ZOkvbFuKd1kRniBx_PD' \
--data-urlencode 'grant_type=client_credentials'
Get the token from access_token
{
"access_token": "eyJhcGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImNjdEwwV3AtNkMtYnk1NHlfM0k3UCJ9.eyJodHRwczovL3JpbmdyaW5nL2NsaWVudF9yZXNlbGxlcklkIjoiMSIsImh0dHBzOi8vcmluZ3JpbmcvY2xpZW50X05ld0N1c3RvbWVySWQiOiJlYTliMjM2OC1mMjgzLTQ5ODgtYmI0Ny1kZjA3MjJiN2Q3MDEiLCJodHRwczovL3JpbmdyaW5nL2NsaWVudF9vbGRDdXN0b21lcklkIjoiNzU2MCIsImh0dHBzOi8vcmluZ3Jpbmcvcm9sZSI6Ik93bmVyIiwicm9sZSI6Ik93bmVyIiwiaHR0cHM6Ly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Tp1c2Vyc192MiIsInJlYWQ6dXNlcnNfdjIiLCJyZWFkOnNtcy10ZW1wbGF0ZXMiLCJ3cml0ZTpzbXMtdGVtcGxhdGVzIiwicmVhZDpwaW5nIiwicmVhZDpjcmVkZW50aWFscyIsIndyaXRlOmNyZWRlbnRpYWxzIiwicmVhZDpwZW9wbGUiLCJ3cml0ZTpwZW9wbGUiXX0.zK12A2ongayYsXTbgyBAfZNA5cZPpu17P3Lu6uA0g4HxW4xvSmS-6kVtVg8XTqwYS25IxVsRyET7LSVBcoctw1DUW8FeB6cHVKVOjODGjLv5waXjV-DHiqPcWuL-xoxXughyZ4I4S5hWMFW5NoVzxNQBH4LMcqcdqiYWDxnrn3d_0M-bOwN8wOwV7t69h0qjMnEIRWbgADlpIhOwSn7_E5unSqWMPn4IMbOnr_uST-Y6NMJu6J42FBQ-nQrEZrGdbgtLVfUlyAeBXf2NrbRG5MYuFlIuPXY-wGz0B7XL_jTJdJqlKT0EjfcizFZaHg6bT6FQNx5wtFtLOpr6kKyZgg",
"scope": "profile:users write:users read:customers write:customers read:contacts write:contacts read:users read:search write:search read:emailsettings write:emailsettings send:email write:teams read:teams readsensitive:contacts read:contacts-settings write:audiences write:feeds write:segments write:attributes write:calendars read:calendars write:surveys read:surveys read:surveys-reporting read:audiences write:webhook-manager read:webhook-manager write:customers-settings read:customers-settings write:users_v2 read:users_v2 read:sms-templates write:sms-templates read:ping read:credentials write:credentials read:people write:people",
"expires_in": 85459,
"token_type": "Bearer"
}
Use the token in a subsequent request by adding the token to the header.
You can use our ping endpoint; you should receive an HTTP status 200.
curl --location 'https://api.naxai.com/ping' \
--header 'Authorization: Bearer eyJhcGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImNjdEwwV3AtNkMtYnk1NHlfM0k3UCJ9.eyJodHRwczovL3JpbmdyaW5nL2NsaWVudF9yZXNlbGxlcklkIjoiMSIsImh0dHBzOi8vcmluZ3JpbmcvY2xpZW50X05ld0N1c3RvbWVySWQiO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WQ6c3VydmV5cy1yZXBvcnRpbmciLCJyZWFkOmF1ZGllbmNlcyIsIndyaXRlOndlYmhvb2stbWFuYWdlciIsInJlYWQ6d2ViaG9vay1tYW5hZ2VyIiwid3JpdGU6Y3VzdG9tZXJzLXNldHRpbmdzIiwicmVhZDpjdXN0b21lcnMtc2V0dGluZ3MiLCJ3cml0ZTp1c2Vyc192MiIsInJlYWQ6dXNlcnNfdjIiLCJyZWFkOnNtcy10ZW1wbGF0ZXMiLCJ3cml0ZTpzbXMtdGVtcGxhdGVzIiwicmVhZDpwaW5nIiwicmVhZDpjcmVkZW50aWFscyIsIndyaXRlOmNyZWRlbnRpYWxzIiwicmVhZDpwZW9wbGUiLCJ3cml0ZTpwZW9wbGUiXX0.zK12A2ongayYsXTbgyBAfZNA5cZPpu17P3Lu6uA0g4HxW4xvSmS-6kVtVg8XTqwYS25IxVsRyET7LSVBcoctw1DUW8FeB6cHVKVOjODGjLv5waXjV-DHiqPcWuL-xoxXughyZ4I4S5hWMFW5NoVzxNQBH4LMcqcdqiYWDxnrn3d_0M-bOwN8wOwV7t69h0qjMnEIRWbgADlpIhOwSn7_E5unSqWMPn4IMbOnr_uST-Y6NMJu6J42FBQ-nQrEZrGdbgtLVfUlyAeBXf2NrbRG5MYuFlIuPXY-wGz0B7XL_jTJdJqlKT0EjfcizFZaHg6bT6FQNx5wtFtLOpr6kKyZgg'
Credentials in Header
Client Id and Secret can be passed in the header of every request using the headers: X-Client-Id
and X-Client-Secret
.
Naxai doesn't recommend this method, but we understand that some Iot devices or specific applications cannot manage the Client Credentials flow of OAuth2.
When using this authentication method, we recommend you create an additional Client Id and Secret pair available on your account settings page.