AdTech Quickstart

This guide explains how to get started with your account to leverage the integrations of n_2 for your AdTech.

Use case

Imagine you are building a tool that helps marketers manage their ad campaigns across multiple platforms. Your customers would need to connect their ad accounts to your tool in order for your app to access their data and manage their campaigns. This would require you to integrate with multiple ad platforms. n_2 can help you achieve the same faster by providing a single API to access all the major ad platforms.

This however requires your app's customers to connect their ad accounts to n_2. This guide will help you understand how to get started with n_2 and integrate it into your app.

Prerequisites

In order to follow this guide, you need to do the following:

  1. Log in to your account: Before you start, you need to have an n_2 account. If you don't have one yet, you can sign up here.
  2. Create a company token: A company token is used to make API calls against n_2 in the name of a company. Visit the Integrations page to retrieve your company token. Keep it safe and do not share it with anyone. In case you suspect that it has been compromised, revoke it immediately.

Customer accounts

In order to represent your app's customers in n_2 and connect their ad accounts, you need to create a customer account for each of your customer. This account will be used to manage the customer's ad accounts and make API calls on their behalf.

Interactive/customers

Create a customer account

To create a customer account, you need to make a POST request to the /customers endpoint. The request body should include the following parameters:

  • Name
    name
    Type
    string
    Description

    Name of the customer. This can be the customer's name or any other identifier.

curl -X POST https://api.n2api.io/customers \
  -H "Authorization: Bearer YOUR_COMPANY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "John Doe"}'
Try it
fetch('https://api.n2api.io/customers', { method: 'POST', body: {"name":"John Doe"} })

Interactive/customers/<id>/connect

Connect customer ad accounts

Once you have created a customer account, you can redirect your user to the connection page where they can connect their ad accounts. The connection page is a hosted page provided by n_2 that allows customers to connect their ad accounts to n_2.

To redirect your customer to the connection page you can either create a redirect URL manually or by making a GET request to the /customers/<customer_id>/connect endpoint. The request should include the following query parameters:

  • Name
    customer_id
    Type
    string
    Description

    ID of the customer account you created.

curl -X GET https://api.n2api.io/customers/<customer_id>/connect \
  -H "Authorization: Bearer YOUR_COMPANY_TOKEN"
Try it
fetch('https://api.n2api.io/customers/<customer_id>/connect', { method: 'GET' })

If successful, the response body will include a connect_url parameter. You can direct your user to this URL to connect their ad accounts.

{
  "connect_url": "https://api.n2api.io/connections?customer=YOUR_CUSTOMER_ID
    &token=SESSION_TOKEN&redirect_uri=YOUR_REDIRECT_URI"
}

This redirect_uri can be used to redirect your customer to the connection page that looks like this:

Screenshot of a page showing ad tech company logos

Once your customer has gone through the ad platforms authentication process, they will be redirected to n_2's connection success page. This is where we connect the ad accounts to n_2 and retrieve the access tokens. The connect page looks like this:

Screenshot of a website that indicates success and redirection of the viewer

This page will only be shown for a short period of time and will then redirect the user back to your app using the redirect_uri parameter.


Interactive/customers/<id>

Check connection status

After the customer has connected their ad accounts, you can check the connection status by making a GET request to the /customers/<customer_id> endpoint. The request should include the following query parameters:

  • Name
    customer_id
    Type
    string
    Description

    ID of the customer account you created.

curl -X GET https://api.n2api.io/customers/<customer_id> \
  -H "Authorization: Bearer YOUR_COMPANY_TOKEN"
Try it
fetch('https://api.n2api.io/customers/<customer_id>', { method: 'GET' })

If successful, the response will include a list of connected ad accounts along with their status.

Make API calls on behalf of the customer

Once the customer has connected their ad accounts, you can make API calls on their behalf. The API calls should include the customer_id parameter to specify the customer account you are making the call for.

curl -X GET https://api.n2api.io/campaigns?customer=YOUR_CUSTOMER_ID \
  -H "Authorization: Bearer YOUR_COMPANY_TOKEN"

This will return a list of campaigns for the connected ad accounts of the specified customer.

Was this page helpful?