API Open Endpoints
API Open Endpoints
Open Endpoints are API calls designed for simplified use of the REST API functionality. The primary use case for the Open Endpoints is in client-server interactions, such as through a mobile app. These actions typically involve looking up information about an advocate or whom they’ve referred.
Some examples include:
- Look up a referral code after app install to display a dialog about who referred them
- Register a new user in the referral program
- Look up share links to display a custom sharing dialog
- Look up referrals to display a list of referred friends
Authentication options
- Authentication via JSON Web Token (JWT) - JWTs can be used for requests that require authentication. The process for building JWTs is outlined in our JSON Web Tokens documentation. Use for client-server communication.
- Authentication via API Key - Your API key can also be used for requests that require authentication. Use for server-server communication.
- Unauthenticated - Some Open Endpoints do not require any form of authentication.
Authentication Requirements by Method
The following table summarizes the Open Endpoint methods that are available for use, and their required level of authentication:
Open Endpoint method | Authentication required |
---|---|
Create a user | Write Token or API key |
Upsert a user | Write Token or API key |
Lookup a user | Read Token or API key |
Lookup a user by referral code | No authentication required. |
Lookup a referral code | No authentication required. |
Apply a referral code | Write Token or API key. |
List referrals | Read Token or API key. |
Authentication with JWT
Authentication with JWTs should be used in client-server, not server-server communication.
The Advocate API accepts two types of JWTs: read tokens and write tokens. Read tokens are intended to validate a request to lookup information about an existing user/account while write tokens are intended to be used when adding or updating information about a user/account.
The format of the JWT payloads required for read and write tokens are outlined below:
Read Token Payload
The payload of a read token is based on the user id
and account id
:
{
"user": {
"id": "adfgafdg",
"accountId": "adfklajdnrerereACdsedf"
},
"exp": 1462327764 //optional date in seconds since the epoch
}
Write Token Payload
The payload of a write token can contain the complete user object:
{
"user": {
"id": "adfgafdg",
"accountId": "adfklajdnrerereACdsedf",
"email": "[email protected]",
"firstName": "Bob",
"lastName": "Testerson", //optional
"locale": "en_US", //optional
"referralCode": "BOBTESTERSON", //optional
"imageUrl": "" //optional
},
"exp": 1462327764 //optional date in seconds since the epoch
}
Building the JWT
Tip:
The process for building the JWT is outlined on our JSON Web Tokens page.
Make sure that you are trying to sign the correct format of the payload (Read Token vs. Write Token) for your specific Open Endpoint API call.
Authentication with API Key
Authentication with your API key should be done when conducting server-server communication.
Tip
Authenticating Open Endpoint calls with an API key is done in the same way as with our standard API calls, details for which can be found in API Authentication.
Updated 10 months ago