Raw requests
Raw requests allow developers to make direct API calls to underlying platforms, bypassing platform App reviews for quicker access. This feature is perfect for testing new features or API endpoints, which are not yet supported by n_2, enabling more flexibility and full access to the underlying platform.
Supported Platforms
The generic /raw endpoint is currently supported for the following platforms:
You can find the official API documentation for each platform here:
- Facebook Ads API Documentation
- Google Ads API Documentation
- LinkedIn API Documentation
- Microsoft Advertising API Documentation
The following platforms are currently being integrated:
See the Supported Platforms page for a full list of platforms and their integration status in n_2.
How to use it
To send a raw request, instead of making a request directly to the platform’s API, route it through n_2’s raw endpoint.
Request Format: Use the same format as the underlying platform API for the request:
- Ensure the method, headers, query parameters, and request body match the request of the underlying platform API, except the credentials.
- Authentication for the underlying platform: There is no need to send authentication details for the underlying platform. n_2 will handle authentication using the credentials provided by the customer during login.
Simply include the
customerIdin the URL. You can find the customerId at Customers.
Request
curl -X METHOD \
"https://n2.pi-automate.com/{platform}/{customerId}/raw/" \
-H 'accept: application/json' \
-H 'Authorization: Bearer <access_token>'
- Authentication for n_2: You must include the access token provided by n_2 in the Authorization header of the request. This token is used to authenticate your request with n_2.
- Format the request URL as https://n2.pi-automate.com/{platform}/{customerId}/raw/
- The
platformparameter should be replaced with the platform you are targeting:facebook,googleads,pinterest,activeagent,thetradedesk,linkedinormicrosoftads.
A first example
List all Facebook ad accounts
This example requests a list of all ad accounts associated with the authenticated user on the Facebook platform.
fetch('https://n2.pi-automate.com/facebook/<customerId>/raw/v22.0/me/adaccounts', {
method: 'GET'
})
Fill in customerId to send the request.
List all Google Ads accessible customers
This example requests a list of all accessible customers associated with the authenticated user on the Google Ads platform.
fetch('https://n2.pi-automate.com/googleads/<customerId>/raw/v21/customers:listAccessibleCustomers', {
method: 'GET'
})
Fill in customerId to send the request.
List all ad accounts of Pinterest account
This example requests a list of all ad accounts associated with the authenticated user on the Pinterest platform.
fetch('https://n2.pi-automate.com/pinterest/<customerId>/raw/v5/ad_accounts?', {
method: 'GET'
})
Fill in customerId to send the request.
List current user information of ActiveAgent account
This example requests the current user information associated with the authenticated user on the ActiveAgent platform.
fetch('https://n2.pi-automate.com/activeagent/<customerId>/raw/latest/users/current', {
method: 'GET'
})
Fill in customerId to send the request.
List all The Trade Desk partners
This example requests a list of all partners associated with the authenticated user on the The Trade Desk platform.
fetch('https://n2.pi-automate.com/thetradedesk/<customerId>/raw/v3/partner/query', {
method: 'POST' , body: {"PageSize":null,"PageStartIndex":0}
})
Fill in customerId to send the request.
List all LinkedIn ad accounts
This example requests a list of all ad accounts associated with the authenticated user on the LinkedIn platform.
fetch('https://n2.pi-automate.com/linkedin/<customerId>/raw/rest/adAccounts?q=search', {
method: 'GET', headers: {"LinkedIn-Version":"202509"}
})
Fill in customerId to send the request.
Microsoft Advertising: get the current user
Microsoft Advertising has several REST services, each on its own host. n_2 picks the host from the first path segment after /raw/:
CampaignManagement, CustomerManagement, CustomerBilling, Reporting, Bulk or AdInsight. The rest of the path is the
Microsoft Advertising REST API v13 operation. Reads and adds are POST, updates are PUT and deletes are DELETE. All of them take a JSON body, and ids are JSON strings.
n_2 adds the Authorization and DeveloperToken headers for you. Send Content-Type: application/json; other body types are refused. A request body may be up to 100 KB.
This example returns the Microsoft Advertising user behind the connection. It needs no additional headers.
Request
curl -X POST \
"https://n2.pi-automate.com/microsoftads/{customerId}/raw/CustomerManagement/v13/User/Query" \
-H 'Authorization: Bearer <access_token>' \
-H 'Content-Type: application/json' \
-d '{"UserId": null}'
fetch('https://n2.pi-automate.com/microsoftads/<customerId>/raw/CustomerManagement/v13/User/Query', {
method: 'POST' , body: {"UserId":null}
})
Fill in customerId to send the request.
Response (abbreviated)
{
"response": {
"User": { "Id": "1234567", "UserName": "jane@example.com" },
"CustomerRoles": [
{ "RoleId": 16, "CustomerId": "123456789" }
]
}
}
Microsoft Advertising: list the ad accounts
Search the accounts the user can access with the User.Id from the previous response. For an account of the user's own customer, ParentCustomerId and Id are the two ids the Campaign Management service asks for.
Request
curl -X POST \
"https://n2.pi-automate.com/microsoftads/{customerId}/raw/CustomerManagement/v13/Accounts/Search" \
-H 'Authorization: Bearer <access_token>' \
-H 'Content-Type: application/json' \
-d '{"Predicates": [{"Field": "UserId", "Operator": "Equals", "Value": "1234567"}], "PageInfo": {"Index": 0, "Size": 100}}'
fetch('https://n2.pi-automate.com/microsoftads/<customerId>/raw/CustomerManagement/v13/Accounts/Search', {
method: 'POST' , body: {"Predicates":[{"Field":"UserId","Operator":"Equals","Value":"<microsoftUserId>"}],"PageInfo":{"Index":0,"Size":100}}
})
Fill in customerId, microsoftUserId to send the request.
Response (abbreviated)
{
"response": {
"Accounts": [
{ "Id": "987654321", "Name": "Example account", "Number": "X1234567", "ParentCustomerId": "123456789" }
]
}
}
Microsoft Advertising: list the campaigns of an ad account
Campaign Management operations need two extra headers: CustomerId, the Microsoft manager account, and CustomerAccountId, the ad account.
Both are Microsoft ids, not the n_2 customer id in the URL. n_2 forwards them unchanged. AccountId in the body must equal CustomerAccountId.
Request
curl -X POST \
"https://n2.pi-automate.com/microsoftads/{customerId}/raw/CampaignManagement/v13/Campaigns/QueryByAccountId" \
-H 'Authorization: Bearer <access_token>' \
-H 'Content-Type: application/json' \
-H 'CustomerId: 123456789' \
-H 'CustomerAccountId: 987654321' \
-d '{"AccountId": "987654321", "CampaignType": "Search"}'
fetch('https://n2.pi-automate.com/microsoftads/<customerId>/raw/CampaignManagement/v13/Campaigns/QueryByAccountId', {
method: 'POST', headers: {"CustomerId":"<microsoftCustomerId>","CustomerAccountId":"<microsoftAccountId>"} , body: {"AccountId":"<microsoftAccountId>","CampaignType":"Search"}
})
Fill in customerId, microsoftCustomerId, microsoftAccountId to send the request.
Response (abbreviated)
{
"response": {
"Campaigns": [
{ "Id": "5551234", "Name": "Brand", "CampaignType": "Search", "Status": "Active", "TimeZone": "AmsterdamBerlinBernRomeStockholmVienna" }
]
}
}
n_2 answers 200 whenever Microsoft returns JSON, also when Microsoft reports an error. A Microsoft error is an object whose Type ends in Fault or FaultDetail, for example AdApiFaultDetail or ApiFaultDetail, with a list of errors. A successful call can carry a PartialErrors list for the items that failed. Check the body of every response.
n_2 itself answers 400 when the first path segment is not one of the six services, 404 when the customer has no Microsoft Advertising connection, and 409 in two cases that the message of the response tells apart:
- The customer's authorization has expired or was revoked. Delete the connection with
DELETE /microsoftads/credentials/{customerId}and connect the customer again. - Microsoft does not accept the n_2 app for the customer. An administrator of the Microsoft tenant the customer signed in with has to check that the app and the Microsoft Advertising API are enabled there. Keep the connection: connecting again does not help.
Response format
n_2 returns the platform's JSON unchanged, wrapped in an object:
- Google Ads and The Trade Desk:
{ "responses": <platform JSON> } - Facebook, Pinterest, ActiveAgent, LinkedIn and Microsoft Advertising:
{ "response": <platform JSON> }