Getting Started With the Bing Ads API
Any Bing Ads user with a developer token can begin using the Bing Ads Application Programming Interface (API). For advertisers placing a large number of ads or developers building advertising tools, the Bing Ads API provides a programmatic interface to Bing Ads. You can write your Bing Ads application in any language that supports web services. Code examples are available in C# (Getting Started | Examples), Java (Getting Started | Examples), PHP (Getting Started | Examples), and Python (Getting Started | Examples). For more information about available services, see Bing Ads API Overview.
To use Bing Ads APIs, you must have a developer token and valid user credentials. If you do not yet have a Bing Ads account, go to the Bing Ads web application, and click Sign up. To get a developer token for production, you must be logged into the Bing Ads Developer Portal as a Microsoft Account user with the Super Admin role. The Super Admin may request API access for any user within their customer scope. For more information, see User Roles and Available Service Operations.
The sandbox and production environments use separate credentials. For information about getting immediate access to the sandbox, see Sandbox.
Bing Ads services use Simple Object Access Protocol (SOAP) to exchange the request and response messages with the service operation. For more information, see Bing Ads Services Protocol.
Each SOAP request must include the following SOAP headers, which contain the user’s credentials.
|The application-access token.||No. This header element is not used and should be null.|
|The OAuth access token used to manage Bing Ads accounts linked to a Microsoft Account. For more information, see Managing User Authentication with OAuth.||Required if the |
|The identifier of the account that owns the entities in the request. This header element must have the same value as the ||Required for service operations related to ad extensions and bid estimations. As a best practice you should always specify this element for operations limited in scope to a single account per service call.|
|The identifier of the customer that owns the account.||Required for service operations related to targeting and editorial. As a best practice you should always specify this element.|
|The client application's developer access token.||Yes.|
|The Bing Ads user's sign-in password.||Required if the |
|The Bing Ads user's sign-in user name. You may not set this element to a Microsoft account.||Required if the |
Many Bing Ads service operations require an account ID and some require a customer ID. The following sections describe the account and customer identifiers, and provides information on retrieving the identifiers.
The account identifier is a numeric identifier that identifies an account.
Many of the campaign management operations require that you specify the account identifier in the body of the request message. For example, the GetCampaignsByAccountId operation returns all of the campaigns for the account that you specify in the body of the request message.
Do not confuse the account identifier with the account number. The account number is the system generated account number that is used to identify the account in the Bing Ads web application. The account number has the form xxxxxxxx, where xxxxxxxx is a series of any eight alphanumeric characters.
The API uses only the account identifier, never the account number.
The customer account identifier is the same as the account identifier. You specify the account identifier in the
CustomerAccountId SOAP request header element.
As a best practice you should always specify the identifier of the account being accessed in the
CustomerAccountId header element. Some of the campaign management operations require that you specify the account ID in the request message, and most of them require that you specify the account ID in the
CustomerAccountId header element.
The customer identifier is the numeric identifier that identifies a customer. You specify the customer identifier in the
CustomerId SOAP request header element.
As a best practice you should always specify the identifier of the customer that owns the account in the
CustomerId header element. Only operations that store data in the customer library for example targets, require you to set the
CustomerId header element. Operations that require you to specify the customer ID will state this in the corresponding service operation topic.
To get a user’s customer ID and account ID, you can sign in to the Bing Ads web application and click on an account within Accounts & Billing. The URL will contain a
cid key/value pair in the query string that identifies your customer ID, and an
aid key/value pair that identifies your account ID. For example,
For troubleshooting tips, see Handling Service Errors and Exceptions.
To get help with issues that you cannot resolve, consider posting in the API Developer Forum where an active Bing Ads product team or community member will try and help. If you do not find timely information via the developer forum, or if the investigation involves sensitive account or personal details, please contact Bing Ads Support.