Get started with Moloco Ads API
This page helps you get started with Moloco Ads API.
Before you start
To make requests to Moloco Ads API, you need to be signed in as a Moloco Ads user. If you don't already have an account with us, please reach out to a Moloco representative to sign up for one. Moloco will create your account and assign it to a workplace, where you can manage everything related to creating, launching, and analyzing campaigns.
Important:
When you sign up, be sure to use a valid email address where you can receive email communications from us. We will be periodically sending out important communications regarding any upcoming API version deprecations, updates to existing API endpoints, etc.
After your account has been created, you should receive an email to reset your password. You must click the link in the email and reset your password to be able to access your account.
Note: You must be using Transport Layer Security (TLS) ver. 1.2 or later to be able to use our services. If you need help setting up or upgrading to TLS ver. 1.2 or later, reach out to your Moloco representative.
At this time, we offer the following options for getting access to the Moloco Ads APIs.
Option # 1: Get an access token with ID and password
To be able to make requests to Moloco Ads API, you must have a Moloco-issued access token. To get an access token, you must make a POST API request with your Moloco account email address and password.
Keep in mind:
If you are using Single Sign On (SSO) or two-factor authentication (2FA) to sign in, you must instead use your API key to get an access token.
The following example shows you how you can use your command-line interface to make a POST API request to get an access token from Moloco. For workplace_id
, copy over the workplace ID for the workplace your account has been assigned to. For email
, enter your Moloco account email address. For password
, enter your Moloco account password. To learn more about the process, see Create a new token.
$ curl -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"workplace_id":"$WORKPLACE_ID","email":"$EMAIL","password":"$PASSWORD"}' \
https://api.moloco.cloud/cm/v1/auth/tokens
{
"token":"$TOKEN"
}
As in the following example, the response includes your access token, which is the value of the token
property. You must include your access token in the Authorization
header like the following when making requests to Moloco Ads API.
Authorization: Bearer $TOKEN
Note: Your API requests are rejected in the event that you have failed to include an access token, included the incorrect token, or your token has expired. An access token is valid for 30 days, and you must periodically refresh the token before it expires. For more information, see Refresh the existing token.
Option # 2: Get an access token with your API key
If you would like an additional layer of security, you can opt in to start using API keys rather than your personal information to generate an access token. To create an API key, you must sign in to Moloco Ads and follow these instructions. After you have created an API key, you must make a POST API request with your API key as in the following example.
Keep in mind:
If you opt in to use 2FA or are using Single Sign On (SSO), you are required to use an API key to get an access token and will no longer be able to use your personal information to get an access token.
The following example shows you how you can use your command-line interface to make a POST API request to get an access token from Moloco. For api_key
, copy over the API key you have created in Moloco Ads DSP.
$ curl -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"api_key":"$API_KEY"}' \
https://api.moloco.cloud/cm/v1/auth/tokens
{
"token":"$TOKEN"
}
As in the example, the response includes your access token, which is the value of the token
property. You must include your access token in the Authorization
header like the following when making requests to Moloco Ads API.
Authorization: Bearer $TOKEN
Note: Your API requests are rejected in the event that you have failed to include an access token, included the incorrect token, or your token has expired. An access token is valid for 30 days, and you must periodically refresh the token before it expires. For more information, see Refresh the existing token.
Updated about 1 month ago