Getting started
- application_id, provided to you from Whiplash.
- client_secret, provided to you from Whiplash.
- user_scope, which will be user_read or user_manage. This will be provided to you from Whiplash.
- callback_url, which you can provide to us during V2 signup, or we can assign a temporary one to you.
- A Whiplash web app login and password for the appropriate API environment (Sandbox for testing, production for real data).
Note: You will be required to manually create your initial Oauth token via Whiplash App authentication. Once the relationship has been established, you can skip the manual login flow and just request refresh tokens.
Authenticating
Sandbox URL: https://sandbox.whiplash.app
Production URL: https://www.getwhiplash.com/
- In a browser, issue a GET request to /oauth/authorize
- Include the following parameters:
- scope=YOUR USER SCOPE (usually user_read and/or user_manage)
- response_type=code
- redirect_uri=YOUR CALLBACK_URL FROM ABOVE
- client_id=YOUR APPLICATION ID FROM ABOVE
- https://sandbox.whiplash.app/oauth/authorize?scope=user_manage&response_type=code&redirect_uri=https://hookbin.com/bin/vLNL1rj9&client_id=dbbd69223a50f6d347bb6c1110da12c69a34b1f0a3e69902c5db3e3a03bf58d5
If not already logged in, you will be prompted to authenticate in the Whiplash web app. Do so with your login credentials.
Once you log in, you will be redirected to your redirect_uri with the parameter code appended to it.
Note: We use hookbin.com simply as an example. You can just as easily have this call an endpoint in your application
Retain this code value, referred to as RETURNED_CODE.
Step 2
Make a POST to /oauth/token and include the following key/values in your post body:
- redirect_uri=YOUR CALLBACK_URL
- code=RETURNED_CODE
- client_id=YOUR APPLICATION ID
- client_secret=YOUR CLIENT SECRET
- scope=YOUR USER SCOPE
- grant_type=authorization_code
{ "access_token": "ddb8c266333a19...", "token_type": "bearer", "expires_in": 7200, "scope": "user_manage", "created_at": 1510698627 "refresh_token":"8c488ab5f75d61..." }
This token will remain active for 2 hours. After, you will need to get a refresh token. Hang on to the value of "refresh_token" so you will be able to get new tokens when this one expires.
TIP: If you get an "Invalid_grant" error, please reach out to the Tech Support Team. This is likely due to an expired or invalid callback URL.
Step 3
You can now make an API request to Whiplash on behalf of the user you authenticated as in Step 1.
Simply add the Header Authorization:"Bearer YOUR_ACCESS_TOKEN" (using the above example - Authorization: "Bearer ddb8c266333a19..." )
With that Header set, you can now call V2 API endpoints such as: https://sandbox.whiplash.app/api/v2/items
Expiration & Refresh tokens
The access token has a “time-to-live” (ttl), which is the maximum time that the access token will be valid for use within the application. By default, all tokens have a system-defined ttl of 2 hours (7200 seconds). When a token is created, the API response will return the ttl in seconds.
You will use your refresh token that gets regenerated every time you use the previous token to re-authenticate periodically every 2 hours. We recommend storing refresh tokens in a secure location, such as a password-protected file system or an encrypted database to share amongst your team members who require them to make API calls.
- grant_type="refresh_token"
- refresh_token=YOUR REFRESH TOKEN
- client_id=YOUR APPLICATION ID
- client_secret=YOUR CLIENT SECRET
This will return a new token response like:
{ "access_token": "ddb8c266333a19...", "token_type": "bearer", "expires_in": 7200, "scope": "user_manage", "created_at": 1510698627 "refresh_token":"8c488ab5f75d61..." }
You can now use the newly returned access_token as the value for your Authorization Header and retain the new refresh_token for future refresh calls.
V2 Rate Limiting
You can find the rate limit and how many attempts you have left in the response header. The fields you'll want are to this are...
X-Ratelimit-Limit - Your rate limit caps out at this value
X-Ratelimit-Remaining - How many attempts you have left
Example in Postman/Post Request:
Troubleshooting API issues
If the issues persist, please contact Support at support@whiplash.com for further assistance.
Related Questions:
How do I authenticate to the Whiplash V2 API?
How do I obtain a refresh token?
How do I troubleshoot an issue with the API?