Account Assignments API v2.0

The Account Assignments API lets you list all hotels in the specified account or sub account, and, optionally, its sub accounts. You can also move (or re-assign) hotels from one account or sub account to another.

Path

base_path/api_version/account_id/assignments[/destination_account_id]

Where:

Path Parameter Description
base_path https://www.googleapis.com/travelpartner
api_version v2.0
account_id A parent account or sub account ID. When re-assigning hotels with a PUT request, this account must be a common ancestor of the hotels' accounts as well as the destination account.
destination_account_id The account to which hotels are reassigned during a PUT request.

Query String Parameters

Parameter Description
include_subaccounts Set to "true" to get a list of all hotels in the specified account and all of its sub accounts. This action is recursive. The default value is "false".
include_names Set to "true" to include both the hotel ID and its name in the response. The default value is "false".

Supported Methods

HTTP Method Description
GET Gets a list of hotels in a particular account or sub account. This action can optionally include sub accounts and the descendents of those sub accounts to return a complete list of hotels in all accounts under the main account.
PUT Moves (or re-assigns) hotels to a single destination account (destination_account_id).

Examples

Lists hotels in the specified account:

GET https://www.googleapis.com/travelpartner/v2.0/4200042/assignments

Lists hotels in the specified account and its sub acccounts:

GET https://www.googleapis.com/travelpartner/v2.0/4200042/assignments?include_subaccounts=true

Lists hotels in the specified account, and includes hotel names in the response:

GET https://www.googleapis.com/travelpartner/v2.0/4200042/assignments&include_names=true

Moves hotels from one or more accounts to a single, destination account:

PUT https://www.googleapis.com/travelpartner/v2.0/4200042/assignments/8675309

Listing hotels in an account

You can use the Account Assignments API to list all hotels in the specified account. The account can be the manager account or a sub account.

To list hotels in an account, send a GET request with the following URL syntax:

GET https://www.googleapis.com/travelpartner/v2.0/account_id/assignments

The following example lists hotels in account 4200042:

GET https://www.googleapis.com/travelpartner/v2.0/4200042/assignments

The Account Assignments API sends a response that contains a list of hotels in the hotels object.

The following sample response shows all hotels in the specified account:

{
  "assignments": [
    {
      "account_id": "4200042",
      "hotels": [
        "master1",
        "master2",
        "master3"
      ]
    }
  ],
  "update_version": "42"
}

To include hotels in the specified account's sub accounts, set the include_subaccounts query string parameter to "true", as the following example shows:

GET https://www.googleapis.com/travelpartner/v2.0/4200042/assignments?include_subaccounts=true

The following sample response shows all hotels in the specified account (4200042), it's sub accounts (10005 and 10006), and any hotels in its sub accounts' sub accounts (10006's child 10007):

{
  "assignments": [
    {
      "account_id": "4200042",
      "hotels": [
        "master1",
        "master2",
        "master3"
      ]
    },
    {
      "parent_account_id": "4200042",
      "account_id": "10005",
      "hotels": [
        "sub1_1",
        "sub1_2",
        "sub1_3"
      ]
    },
    {
      "parent_account_id": "4200042",
      "account_id": "10006",
      "hotels": [
        "sub2_1",
        "sub2_2",
        "sub2_3"
      ]
    },
    {
      "parent_account_id": "10006",
      "account_id": "10007",
      "hotels": [
        "sub3_1",
        "sub3_2",
        "sub3_3"
      ]
    }
 ],
 "update_version": "42"
}

You can optionally include the names as well as the IDs of all hotels in the response by setting the include_names query string parameter to "true" in the request, as the following example shows:

GET https://www.googleapis.com/travelpartner/v2.0/4200042/assignments?include_names=true

The response that includes the hotel names is slightly more complex, pairing each hotel ID with its name in the hotels array, as the following example shows:

{
  "assignments": [
    {
      "account_id": "50001",
      "hotels": [
        {
          "hotel_id": "hotel1",
          "name": "hotel1_name"
        },
        {
          "hotel_id": "hotel2",
          "name": "hotel2_name"
        },
        {
          "hotel_id": "hotel3",
          "name": "hotel3_name"
        }
      ]
    }
  ],
  "update_version": "42"
}

Moving hotels from one account to another

You can use the Account Assignments API to move (or re-assign) hotels to a single destination account.

The accounts that you move hotels from must be children of the account that you specify as the account_id in your URL path. You can also move hotels from the master account, if the master account matches your account_id.

The one account that you move the hotels to is specified at the end of the URL (the destination_account_id). This account must also be a child of the account specified with account_id in the URL.

All accounts involved in the move must be descendants of account_id. This means that they would all appear in a response to a GET that includes include_subaccounts=true.

The maximum number of hotels that you can update in a single request is 15,000. This is the number of hotels that are specified in the API request, not the total number of hotels affected by the request. For example, you can have more than 15,000 hotels in a group that are affected by the request.

To move hotels to a target account, send a PUT request with the following syntax:

PUT https://www.googleapis.com/travelpartner/v2.0/account_id/assignments/destination_account_id

The following example moves hotels to sub account 8675309:

PUT https://www.googleapis.com/travelpartner/v2.0/4200042/assignments/8675309

The body of the PUT request contains one or more hotel IDs that are to be moved. These hotels can be in any account, as long as you have write permissions for those accounts. You specify these hotels in an array of hotel_ids by using the following syntax:

{
  hotel_ids: [
    "hotel_id_1"[,"hotel_id_2",...]
  ]
}

The following example request body contains three hotels that are to be moved:

{
  hotel_ids: [
    "h1066",
    "h1492",
    "h1789"
  ]
}

In this example, the Account Assignments API moves the specified hotels from whichever accounts they are in (as long as they are descendants of account_id) to account 8675309.

The Account Assignments API does not respond to a successful move request. If the move was unsuccessful, the Account Assignments API returns an error object that describes the error.

Account Assignements API Changes

The Account Assignements API is new for v2.0.