Skip to main content

Authentication

The Vendor API uses the OAuth 2.0 Client Credentials flow. This flow is for server-side (confidential) applications with no end user, which usually means machine-to-machine communication.

Natera sends your client ID and client secret by secure email when your organization's account is created. Store them securely and never ship them in client-side code.

Request a token​

Base64-encode client_id:client_secret and send it as HTTP Basic authentication to the token endpoint:

curl --request POST \
--url https://mpx-api-sandbox.natera.com/api/1.0/oauth/token \
--header 'accept: application/json' \
--header 'authorization: Basic <BASE64(client_id:client_secret)>' \
--header 'cache-control: no-cache' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'grant_type=client_credentials&scope=mpx%3Avendor'
ParameterValue
grant_typeclient_credentials
scopempx:vendor

If the credentials are valid, the response contains an access token:

{
"access_token": "eyJhbG[...]1LQ",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "mpx:vendor"
}

Tokens expire after expires_in seconds. Cache the token and request a new one shortly before it expires, rather than requesting one per API call.

Make an authorized request​

Send the token as a bearer token in the authorization header:

curl --request POST \
--url https://mpx-api-sandbox.natera.com/vendor/graphql \
--header 'accept: application/json' \
--header 'authorization: Bearer eyJhbG[...]1LQ' \
--header 'content-type: application/json' \
--data '{"query": "query { __typename }"}'

If the token is valid but isn't linked to a vendor, requests fail with AUTHORIZATION_VENDOR_NOT_FOUND.