# Audience Segments API Using the Audience Segments API, customers and data providers have control to onboard and activate the [data](http://www.mediamath.com/legal/terms/audiencedata_policy/) they need to target in MediaMath Platform. As it's a self-service solution, turnaround time for updates is reduced from business days to minutes. The API is built using industry standard, open source REST APIs and is a scaleable way to handle all requests for both global and permissioned taxonomies. The service brings transparency to data activation at MediaMath, allowing customers and data providers oversight of relevant 1st and 3rd party audience data sets as well as the permissioning of those data sets.  # Audience Segments & Taxonomies There are two ways to expose the data onboarded via [server-to-server](/guides/server-to-server) within MediaMath Platform: * **Taxonomies** * These can be global, meaning all MediaMath customers will have access to the segments within the taxonomy in MediaMath Platform. * These can be permissioned so that only select MediaMath customers have access to the segments within the taxonomy in MediaMath Platform. * **External Data Segments** * These represent a single segment and are always permissioned. * These are also referred to as Data Pixels. It's possible to use both methods to achieve a mix of global and permissioned taxonomies & external data segments to suit your needs and the needs of your customers. Note: The [S2S data transfer](/guides/server-to-server) is the same for both global and permissioned taxonomies, as well as external data segments. ## Taxonomies (Global) Taxonomies are presented in MediaMath Platform as a hierarchical tree, where the first node (root node) is the data provider's name. Within the tree, media traders can expand selections of categories of segments and view an estimated audience size (the number of unique users) and a CPM price (USD by default). In this view, the Audience Targeting view has been annotated to show the elements of a taxonomy: ![Audience Tab Annotated](https://mediamath.github.io/api-docs/images/audience_tab.png) ## Taxonomies (Permissioned) Similar to global taxonomies, permissioned taxonomies are also presented in MediaMath Platform as a hierarchical tree, where the first node (root node) is the data provider's name. Within the tree, media traders can expand selections of categories of segments and view an estimated audience size (the number of unique users) and a CPM price (USD by default). Permissioned taxonomies can include first and/or third party segments and are 'permissioned' or shared with specified entities, organizations, agencies and/or advertisers in MediaMath Platform. As all taxonomy management utilizes the same underlying MediaMath API, the information shared in this section applies to both global and permissioned taxonomies, with the exception of the visibility of the taxonomy & permissioning.  ### Revenue Share at Taxonomy Level Utilizing the API requires the data provider be set up as a data vendor in our system and that MediaMath act as a clearinghouse for all transactions. For third-party data providers, you'll work out terms with our partnerships team; for customers sharing first-party data, the revenue share will typically be set at 0 by our partnerships team. Each data provider has a default revenue share, mutually agreed upon with the partnerships team; however, this default revenue share value can be overridden at a taxonomy level. For example, if a customer wants to target segments in MediaMath Platform at a rate which they have pre-negotiated with you, their data vendor, the customer's specific rate may require the use of a revenue share different from the default revenue share originally agreed upon between you & MediaMath. To facilitate this, you as the data provider, can create a permissioned taxonomy for the customer and work with the partnerships team to set a revenue share that relates to that specific taxonomy.  To override a revenue share at the taxonomy level, create the taxonomy with permissions and contact [MediaMath Support](https://mediamathsupport.force.com/s/) with the following information: * the Taxonomy_ID, * the desired taxonomy-level revenue share. Our team will respond once they have updated the revenue share for the specified taxonomy. ## Taxonomy Management Taxonomies are managed using one of two methods: * a CSV file provided to [MediaMath Support](https://mediamathsupport.force.com/s/) by the data provider, * using the [API](/apis/audience-taxonomies).  ### Taxonomy Format For data providers not integrated with the API, taxonomies can be managed using a CSV file. | Column Name | Example Value | Description | Type | |-----------------|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------| | `full_path` | \|Data.com\|Age\|30-35\| | Pipe delimited node representation from root (must start with a pipe character) | String | | `code` | 12345 | Data provider's segment identifier, which should be unique to this segment | Integer | | `uniques` | 1000000 | Number of unique users in this segment (rounded estimate) | Integer | | `wholesale_cpm` | 0.80 | The CPM (Cost per Thousand Impressions) that MediaMath will pay the data provider, in US Dollars | Decimal (2dp) | | `retail_cpm` | 1.10 | The CPM (Cost per Thousand Impressions) that Buyers will pay MediaMath, in US Dollars. *This is the value that is shown to buyers in the MediaMath Platform Audience Targeting Tab* | Decimal (2dp) | | `buyable` | 1 | Used to separate segments from non-purchasable categories (which aid navigation in MediaMath Platform). When "1" it will be buyable; when "0" it is not buyable and only requires `full_path` field to be populated. | Integer 1 or 0 | ### Sample Taxonomy **Note**: The full_path always starts with a pipe. | full_path | code | uniques | wholesale_cpm | retail_cpm | buyable | |----------------------------|--------:|---------:|---------------:|------------:|---------:| | \|BlueKai | | | | | 0 | | \|BlueKai\|Group 1| | | | | 0 | | \|BlueKai\|Group 1\|Segment 1| | | | | 0 | | \|BlueKai\|Group 1\|Segment 2| | | | | 0 | | \|BlueKai\|Group 1\|Segment 3| 245244 |661,664| 0.85 | 1 | 1 | | \|BlueKai\|Group 1\|Segment 4| 245245 | 3,585,118 | 0.85 | 1 | 1 | | \|BlueKai\|Group 1\|Segment 5| 245246 | 5,247,410 | 0.85 | 1 | 1 | | \|BlueKai\|Group 2| | | | | 0 | | \|BlueKai\|Group 2\|Segment 6| 245247 | 34,355 | 0.85 | 1 | 1 | | \|BlueKai\|Group 2\|Segment 7| 245248 | 13,248 | 0.85 | 1 | 1 | | \|BlueKai\|Group 2\|Segment 8| 245249 | 8,242,543 | 0.85 | 1 | 1 | | \|BlueKai\|Group 2\|Segment 9| 245250 | 9,857,983 | 0.85 | 1 | 1 | | \|BlueKai\|Group 2\|Segment 10| 245251 | 34,324 | 0.85 | 1 | 1 | ### Providing a Taxonomy via CSV To provide a taxonomy - global or permissioned - for your data in MediaMath Platform: 1. Following the format above, produce a CSV containing your segments 2. Validate the [CSV file](http://taxonomy.datasvc.mediamath.com/) format 3. Submit the properly formatted CSV, along with your vendor ID (obtained from the [partnerships team](/guides/data-onboarding#what-to-expect-during-the-setup-process)) to [MediaMath Support](https://mediamathsupport.force.com/s/) 4. If requesting an update to an existing taxonomy, provide the taxonomy ID in your request as well ## External Data Segments An external data segment (also known as a data pixel) is the output of a pixel mapping process that results in the creation of a single, permissioned audience segment. In contrast to a permissioned taxonomy, which can be managed via API and contain N segments, an external data segment represents one audience segment and is defined within the Onboard section of the Audiences module in MediaMath Platform.  External data segments are permissioned to specific agencies (MediaMath entity structure): organization > agency > advertiser) so all advertisers within the agency will have access to the external data segment. Prior to getting started, the data provider needs to be added to the agency in MediaMath Platform. To have a data provider added, contact your MediaMath representative. If the data provider already has the appropriate access, follow these steps to get your external data segments created: 1. Define an audience segment by creating an External Data Segment in the Onboard tab within the MediaMath Platform Audience module. ![MediaMath Platform Data Pixel](https://mediamath.github.io/api-docs/images/t1_data_pixel_form.png) 2. Provide the pixel IDs created in step 1 to your data provider. 3. Data provider will then submit a ticket directly to `pixelmapping@mediamath.com`, including the following. Include each external data segment mapping in the body of the email (or Support ticket) in the line-separated format below. **Note:** Requests to `pixelmapping@mediamath.com` are handled via an automated process, as long as the formatting below is followed in the subject and body of your email. If the format does not conform, requests will be handled within 1 business day. External Data Segment Example Request > Subject Line: Data Provider Pixel Mapping Request > > Description: > > Please map the following > > ns:8473,mm:679001 > > ns:8474,mm:679002 > > ns:8675,mm:679003  ns = the name space of the first pixel being mapped, refer below or reach out to MediaMath support if the namespace is unknown. mm = MediaMath Namespace. This will always be "mm" in the mapping request.   XXXXXX = the partner's segment code sent to MediaMath via S2S.  YYYYYY = the MathTag ID ("MT_ID") associated with the MediaMath external data segment pixel created in step one.  Version: 2.0 License: Apache 2.0 ## Servers ``` https://api.mediamath.com/dmp/v2.0 ``` ## Security ### OAuth2 Type: oauth2 Token URL: https://auth.mediamath.com/oauth/token Scopes: ### Cookie_Auth Cookie: adama_sesion=`cookie-id`. Security: API Key - Please note that adama_cookie support is being deprecated and will be removed in our future v2 API. Type: apiKey In: header Name: Cookie ## Download OpenAPI description [Audience Segments API](https://apidocs.mediamath.com/_spec/apis/audience-taxonomies.yaml) ## Permission Taxonomies _ ### Create Permission Taxonomy - [POST /audience_segments](https://apidocs.mediamath.com/apis/audience-taxonomies/permission-taxonomies/post_audience_segments.md): To create a new permission taxonomy, submit a POST with the Content-Type set to "application/json". The body of the API call will be raw JSON and consists of 3 sections: * You may provide any number of permissions to allow entities in TerminalOne (organizations, agencies and/or advertisers) access to the taxonomy. These organization, agency, and advertiser IDs can be entered as comma separated values within the ‘permissions’ section of the body. To identify IDs for your customers, reach out to MediaMath Support or ask your customer to locate their IDs within TerminalOne's Admin module.  * Every taxonomy rolls up to a MediaMath data vendor entity. The data vendor ID will need to be provided when you create new taxonomies. This ID will be provided to you by the partnerships team. * This describes the way in which the taxonomy will be shared in TerminalOne. This will be a hierarchical tree structure format (root node > leaf node > leaves). ### Example Taxonomy (Permissioned) JSON ### Segment Codes : If you are using a segment code that is not a 32-bit integer, pass an optional parameter as part of the JSON request. Additionally, ensure the user files delivered to the MediaMath server note the declaration to ensure proper processing and handling of the user files and taxonomy. ### Segment Name : Segment name values should not exceeded 255 characters. If you are using a segment name that does not contain latin alphabetic letters then you can convert the name to an ASCII value and pass the encoded name in the POST request. It will then display in the orginal text in T1. Please make sure the ASCII value is encoded using HTML Entities. ### API Response Upon issuing a POST to create the taxonomy, you'll note the following within the : * represents the taxonomy object in our database and rolls up to your data vendor ID. When updating the taxonomy, reference this ID. * represents the individual taxonomy and must be referenced when you want to update the taxonomy. id* represents the MediaMath object you have just created. When updating a taxonomy, include id to ensure the objects - non-buyable nodes or individual segments - are processed as updates and not new additions to the taxonomy. * represents the revenue share agreed upon with MediaMath. * represents the amount the data vendor will accrue when the segment is inclusion or exclusion targeted within a TerminalOne strategy.  * will equal "GLOBAL" for all public taxonomies and "RESTRICTED" for all permissioned, or private, taxonomies. Responses for permissioned taxonmies will not include this optional parameter; API responses for global taxonomies will always include the parameter. ### Example Taxonomy (Permissioned) Creation Response JSON ### List Permission Taxonomies - [GET /audience_segments](https://apidocs.mediamath.com/apis/audience-taxonomies/permission-taxonomies/get_audience_segments.md): Query parameters should be of the form (field)(operator)(value) where operator can be == (equal to) or =: (like) Example: /?q=name=:MediaMath will return segments within your taxonomies that have names like "MediaMath." ### Get Permission List - [GET /audience_segments/grants/{vendor_id}](https://apidocs.mediamath.com/apis/audience-taxonomies/permission-taxonomies/get_audience_segments-grants-$vendor_org_id.md): This will retrieve entity IDs in the MediaMath Platform (organizations, agencies and/or advertisers) to which you, as a data provider, have access. To identify entity IDs for your customers and request your grants be updated, reach out to MediaMath Support or ask your client to locate their relevants IDs within the MediaMath Platform Admin section.  ### Get Permission Taxonomy - [GET /audience_segments/{taxonomy_id}](https://apidocs.mediamath.com/apis/audience-taxonomies/permission-taxonomies/get_audience_segments-taxonomy_id.md): With a taxonomy ID (obtained by creating a new taxonomy), you can retrieve the taxonomy to review permissions and audience segment details. ### Update Permission Taxonomy - [POST /audience_segments/{taxonomy_id}](https://apidocs.mediamath.com/apis/audience-taxonomies/permission-taxonomies/post_audience_segments-taxonomy_id.md): With a taxonomy ID (obtained from creating a new taxonomy), you can update the taxonomy, change permissions, and add or remove audience segments. To ensure that the entire taxonomy is correct, we recommend updates be done as a 3-step process: 1. GET the existing taxonomy (see example API response with definitions) 2. Identify & make changes (i.e. add/edit permissions, add/remove leaf nodes, change retail CPMs, etc) 3. POST the updated taxonomy