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.


Get an access token with your API key

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.

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.

$ 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 16 hours, and you must create a new token using your API key before it expires.


Frequently Asked Questions

I'm having trouble getting an access token.

If you are getting the {‘the given credential doesn't match with database record", 'status': 401'”} error, first check to make sure that you are able to sign in to Moloco Ads without issues. You must be able to sign in to Moloco Ads to be able to use the Moloco Ads APIs. To generate an access token, be sure to use an API key for the ad account you would like to access.

I'm getting the permission denied error.

{
    "code": 7,
    "message": "permission denied [id:xtE0pGc9XpaXEyeb]",
    "details": [
        {
            "@type": "type.googleapis.com/api.adcloud.common.APIErrorInfo",
            "error_log_id": "xtE0pGc9XpaXEyeb",
            "reason": "PERMISSION_DENIED"
        }
    ]

If you are seeing something like the above, confirm that you are able to sign in to Moloco Ads and access the ad account using the sign in credentials used for generating the API key you are using. For agency accounts, be sure that the API request is for an ad account rather than the workplace.

I'm getting the invalid token type error.

{ "code": 3, 
"message": "\"invalid token type\" has invalid value. [id:wo2fqhGcnBoFu1Qm]", 
"details": [ { "@type": "type.googleapis.com/api.adcloud.common.APIErrorInfo", "error_log_id": "wo2fqhGcnBoFu1Qm" } ] }

If you are seeing something like the above, be sure that you are using Bearer for the Authorization header.


What’s Next