Accessing the API
This guide is for external integrations that need to work on behalf of users. The API is available through theconnect.vetcove.com domain. You will need a Vetcove provision OAuth Application in our system to begin connecting Clinics and making requests. Please reach out to your support contact for help getting started.
Authentication
Authentication to the Vetcove service is done via OAuth 2.0 to grant access to resources on behalf of our users.Important Values
Once an account has been provisioned, head to your Integrator Portal page to view yourClient Id and list of connected clinics.
These are going to be the gateway to interacting with Vetcove.
Available OAuth 2.0 scopes
You will need to specify what type of access the user is granting to your application when going through the OAuth 2.0 consent flow. The available scopes are:
Note that while you may request any of the above scopes, not all features will be accessible to all users through the API.
Clinic Authorization
From your software, add in a “Connect with Vetcove” button that when clicked, will redirect the user (with a GET request) to the following url:connect.vetcove.com/api/clinic/v1/app_store/oauth/authorize/?response_type=code&client_id=<client_id>&scope=<scope>&state=<uri_encoded_state_string>&redirect_uri=<uri>&code_challenge=<code_challenge>&code_challenge_method=S256
Notes:
- The
client_idin the URL is taken from the tokens page - The
scopeis a whitespace-delimited sequence of scopes you are requesting access to - The
statevalue is a url encoded string that will be passed through to the redirect URI - The
redirect_urivalue is a fully-qualified url that has been whitelisted in the Integrator Portal - The
code_challengeis a PKCE code challenge derived from a randomly generatedcode_verifier. Generate a random string (thecode_verifier), then computeBASE64URL(SHA256(code_verifier))to produce thecode_challenge. - The
code_challenge_methodmust beS256
/api/clinic/v1/app_store/oauth/authorize/ will prompt the user to enter valid Vetcove Clinic Credentials. These are credentials that
work on https://pims.vetcove.com.
Successful Authorization
When a clinic successfully completes the Oauth grant, the redirect-uri specified will be called with the query parameters<redirect-uri>?code=<auth_code>&state=<uri_encoded_state_string>
Notes:
- The
codewill expire after 10 minutes and should be used immediately for requesting anaccess_token
Requesting Access Tokens
Once acode has been successfully delivered to your redirect uri, the code, client_id, and client_secret will be used
for requesting access_tokens
This is done with a POST request to connect.vetcove.com/api/external/v1/app_store/oauth/token/ with the payload
- The
codeis a one-time code - The
grant_typeofauthorization_codeis required - The
code_verifieris the original random string used to generate thecode_challengein the authorization request
redirect_uris, then redirect_uri is required as a part of the payload. This value needs to match what was in the /api/clinic/v1/app_store/oauth/authorize/ call. Otherwise, a 400 response code and Mismatching redirect URI. error will be returned.
- The
access_tokenhas an expiry of 60 minutes - The
access_tokencan be stored in temporary storage for subsequent requests - The
refresh_tokenshould be stored in long term storage for subsequent requests - Access Tokens must be submitted via
Authorization: Bearer <access_token>header
Requesting a Refresh Token
We strongly recommend that you build your application to expect token expiry at any time. You can do this by adding an error handler for all requests in case they get an “expired token” error message. To request a new token, make anotherPOST request to connect.vetcove.com/api/external/v1/app_store/oauth/token/ with the payload
- The
refresh_tokenis the the token saved from the previous token grant - The
refresh_tokencan be used only once, and subsequent requests require a newrefresh_token. Note: There is a 5 minute grace period between when arefresh_tokenis used, and when it expires. This is useful when facing network issues during this API call. This means retries using the samerefresh_tokenare allowed within this grace period.