External Inventory Code Service

Some sellers use their own codes to break out their inventory more granularly than by Publisher > Site > Placement. The External Inventory Code Service allows you to register such codes with AppNexus so that you can pass them on ad calls and then report on them. Here's how it works:

  1. You must make a POST call to this service to register an external inventory code with AppNexus prior to steps 2 and 3.
  2. You pass the code as ext_inv_code in the query string of ad calls (see example below).
  3. You report on external_inv_id in one of the following reports:

Example Placement Tag with External Inventory Code:

<script src="http://ib.adnxs.com/ttj?id=1234&ext_inv_code=ABC" type="text/javascript"></script>

REST API

Add a new external inventory code:

POST https://api.appnexus.com/external-inv-code
(external_inv_code JSON)

Modify an external inventory code: 

PUT https://api.appnexus.com/external-inv-code?id=ID
(external_inv_code JSON)

View all of your external inventory codes: 

GET https://api.appnexus.com/external-inv-code

View all external inventory codes for a specific publisher: 

GET https://api.appnexus.com/external-inv-code?publisher_id=PUBLISHER_ID

View a specific external inventory code:

GET https://api.appnexus.com/external-inv-code?id=ID
GET https://api.appnexus.com/external-inv-code?code=CODE

Delete an external inventory code:

DELETE https://api.appnexus.com/external-inv-code?id=ID

JSON Fields

Each combination of publisher_id and code must be unique.

Field

Type (Length)

Description

Default

Required On

id

int

The ID for the external inventory code.

Auto-generated number

PUT/DELETE, in query string

publisher_id

int

The ID of the publisher for which the external inventory code is used. If 0, the code is used across multiple publishers.

0

 

name

string (100)

The name for the external inventory code. This name can be included in Network Publisher Analytics reporting.

 

POST

code

string (100)

The value that will be passed as ext_inv_code in the query string of ad calls. For more details, see Placement Tag Parameters (customer login required).

 

POST

Admin-Only Fields

This section is visible to AppNexus employees only. It lists fields that clients can neither see nor edit.

Field

Type

Description

member_id

int

The ID of the member to which the external inventory code belongs.

Examples

Adding an external inventory code for a specific publisher
$ cat ext_inv_code.json

{
   "external_inv_code": {
      "publisher_id": 103764,
      "code":"55",
      "name":"Code 55"
   }
}

$ curl -b cookies -c cookies -X POST -d @ext_inv_code.json 'https://api.appnexus.com/external-inv-code'

{
    "response": {
        "status": "OK",
        "count": 1,
        "id": 102,
        "start_element": 0,
        "num_elements": 100,
        "external_inv_code": {
            "member_id": 1066,
            "id": 102,
            "publisher_id": 103764,
            "name": "55",
            "code": "Code 55"
        }
        }
    }
}
Adding an external inventory code for use across multiple publishers

In this example, we set publisher_id to 0 to indicate that the external inventory code will be used across multiple publishers.

$ cat ext_inv_code.json

{
   "external_inv_code": {
      "publisher_id": 0,
      "code":"74",
      "name":"Code 74"
   }
}

$ curl -b cookies -c cookies -X POST -d @ext_inv_code.json 'https://api.appnexus.com/external-inv-code'

{
    "response": {
        "status": "OK",
        "count": 1,
        "id": 102,
        "start_element": 0,
        "num_elements": 100,
        "external_inv_code": {
            "member_id": 1066,
            "id": 103,
            "publisher_id": 0,
            "name": "74",
            "code": "Code 74"
        }
    }
}
Updating an external inventory code

In this example, we update external inventory code 102 with a new name.

$ cat ext_inv_code_update

{
   "external_inv_code": {
      "name":"Fresh new name"
   }
}

$ curl -b cookies -c cookies -X PUT -d @ext_inv_code_update.json 'https://api.appnexus.com/external-inv-code?id=102'

{
    "response": {
        "status": "OK",
        "count": 1,
        "id": "102",
        "start_element": 0,
        "num_elements": 100,
        "external_inv_code": {
            "member_id": 1066,
            "id": 102,
            "publisher_id": 103764,
            "name": "Fresh new name",
            "code": "Code 5"
        }
    }
}
Deleting an external inventory code

In this example, we delete external inventory code 102.

$ curl -b cookies -c cookies -X DELETE 'https://api.appnexus.com/external-inv-code?id=102'

{
    "response": {
        "status": "OK"
    }
}