Working with accounts

Depending on your use case, the account object is used in the following way:

The account object fields can change as a result of different parameters such as the following:

  • action

  • instance configuration

  • object type_full

To determine the available fields and appropriate values, you should make available_fields calls and options calls as needed. The Platform API provides informative responses even when the input has errors. Building a request may take a few attempts but the error messages will guide you to the correct request format.

To create an account:

  1. Refer to the authentication topic to obtain an openx3_access_token.

  2. Get the available fields for an account:

    Example 1. Sample available_fields request

    openx_server_name/ox/4.0/account/available_fields --cookie "openx3_access_token=curl http://token_string"

    Where: token_string is a string of characters returned by the GET session request at login.

    Example 2. Sample available_fields response

        "attribute": "type_full", 
        "choices": [      "",       "account.advertiser",       "",       "account.publisher"    ], 
        "field": {}, 
        "http_status": 400, 
        "message": "Field type_full value must be one of \"\", \"account.advertiser\", \"\" or \"account.publisher\" (\"None\" not allowed)", 
        "type": "Value Error", 
        "value": null

    Accounts fields change based the different account types. The response indicates that a type_full value is required.

  3. Modify the request by adding a type_full URI parameter:

    Example 3. Sample type_full account request

    openx_server_name/ox/4.0/account/ --cookie "openx3_access_token=curl http://token_string"

    Within the response, several fields are marked "required": true, such as account_uid. Of the required fields, most include a url field, such as account_uid's "url": "/options/account_options".

  4. To see a list of available options, make the options calls indicated by the URLs. The following call shows an options call for only one of the required fields:

    Example 5. Sample experience options request

    openx_server_name/ox/4.0/options/network_experience_options --cookie "openx3_access_token=curl http://token_string"

    Example 6. Sample experience options response

    [  {    "id": "network.display",     "name": "Display Network"  },   {    "id": "",     "name": "Mobile App Developer"  }]

    By default, the acceptable values are the id values, such as network.display and in the above sample. Some fields reference other API objects, such as the account_uid field. For such fields, their options call will return a list very similar to list calls (such as GET /account).

  5. Build a request to create an account using the following five fields along with type_full:

    Example 7. Sample create account request with experience and status typos

    openx_server_name/ox/4.0/account --cookie "openx3_access_token=curl http://token_string" -X POST
          --header "Content-Type:application/json" --data '{"account_uid":
          "200571f0-accf-fff1-8123-0c9a66", "currency": "USD", "experience":
          "network.displayy", "name": "My Network", "status": "Activee", "type_full":
          "", "timezone": "America/Los_Angeles"}'

    The API returns multiple errors and a field errors dictionary with experience and status keys indicating the values passed in are invalid.

  6. Fix the mistakes and try again:

    Example 9. Sample create account request

    openx_server_name/ox/4.0/account --cookie "openx3_access_token=curl http://token_string" -X POST --header "Content-Type:application/json" --data
          '{"account_uid": "200571f0-accf-fff1-8123-0c9a66", "currency": "USD", "experience":
          "network.display", "name": "My Network", "status": "Active", "type_full":
          "", "timezone": "America/Los_Angeles"}'

    The API returns the full object in the create response. Many fields that were not passed in are filled in with defaults, which depend on things such as instance settings, parent account, and other fields.

    Example 10. Sample create response

    [  {    "account_id": "537227760",     "account_uid": "200571f0-accf-fff1-8123-0c9a66",     "acl_override": {},     "country_of_business": "us",     "created_date": "2013-10-04 05:52:57",     "currency": "USD",     "currency_id": "1",     "deleted": "0",     "experience": "network.display",     "external_id": null,     "hidden": "0",     "id": "537241695",     "instance_uid": "[Code]instance_uid", 
        "modified_date": "2013-10-04 05:52:57", 
        "name": "My Network", 
        "notes": "", 
        "revision": 1, 
        "status": "Active", 
        "timezone": "America/Los_Angeles", 
        "timezone_id": "8", 
        "type": "account", 
        "type_full": "", 
        "uid": "2005a85f-accf-fff1-8123-0c9a66", 
        "v": "3"
  7. Make a read call using the UID field of the newly created account:

    Sample read account request

    curl http://openx_server_name/ox/4.0/account/2005a85f-accf-fff1-8123-0c9a66 --cookie "openx3_access_token=token_string"

    The account appears in the response and also for list calls:

    Sample list accounts request

    curl http://openx_server_name/ox/4.0/account --cookie "openx3_access_token=token_string"

See also

Accounts in the OpenX help.