Step 3: Add Services (New Locations)

With the available services information, you can now start adding service to locations. You can either create a new Location and add services to it in a single call, or you can issue a call to add service to a Location that may already exist.

NOTE: You must include the newlocationId, skus, name, address, city, state, zip, phone, categoryIds fields when creating a Location.

New Location Workflow

Admin API Workflow

The status of the order should transition as follows:

  • from PROCESSING to COMPLETED or CANCELED within a few seconds if there is no potential duplicate

Or,

  • from PROCESSING to REVIEW if there is a potential duplicate conflict within a few seconds, and then from REVIEW to COMPLETED and CANCELED within 48 hours.

First, let’s try adding a Location and adding service in one API call. You are going to send a POST request with all the necessary Location and service information (including a SKU).

POST https://api.yextapis.com/v2/accounts/me/newlocationaddrequests?api_key=API_KEY&v=YYYYMMDD

Request Body:

{
	"newLocationAccountId": "BCC-6364487045",
	"newLocationData": {
		"address": "100 Washington Ave",
		"categoryIds": [1952],
		"city": "St. Louis",
		"countryCode": "US",
		"description": "Visit us now.",
		"featuredMessage": "Visit today.",
		"featuredMessageUrl": "http://www.gatewayarch.com/",
		"id": "BCC-6364487045",
		"isPhoneTracked": false,
		"localPhone": "",
		"locationName": "Gateway Arch",
		"phone": "3145558247",
		"state": "Missouri",
		"suppressAddress": false,
		"websiteUrl": "http://www.gatewayarch.com/",
		"zip": "63102",
		"locationType":"LOCATION"
	},
	"skus": ["SKU-00000275"],
  "newLocationId": "BCC-6364487045"
}

The newLocationAccountId is the ID of the Account in which this new Location will be created. For Partner Portal accounts, this ID could correspond to an existing sub-account or your main account. If it does not, a new Account will be created with the ID you entered. For non-Partner Portal accounts, this field can be omitted from your requests. In this case, we created a new Account since we used an accountId that didn’t exist already.

For more information, see the documentation for the Add Requests: Create (New Location) endpoint.

Response Body:

{
  "meta": {
    "uuid": "e3b934c9-3b41-4f65-a26d-4ac7d865ef00",
    "errors": []
  },
  "response": {
    "id": 204095,
    "locationMode": "new",
    "newLocationId": "BCC-6364487045",
    "newLocationAccountId": "BCC-6364487045",
    "newLocationData": {
      "id": "BCC-6364487045",
      "accountId": "830447",
      "locationName": "Gateway Arch",
      "address": "100 Washington Ave",
      "city": "St. Louis",
      "state": "Missouri",
      "zip": "63102",
      "countryCode": "US",
      "language": "en",
      "suppressAddress": false,
      "phone": "3145558247",
      "isPhoneTracked": false,
      "localPhone": "",
      "categoryIds": [
        "1952"
      ],
      "featuredMessage": "Visit today.",
      "featuredMessageUrl": "http://www.gatewayarch.com/",
      "websiteUrl": "http://www.gatewayarch.com/",
      "description": "Visit us now.",
      "locationType": "LOCATION"
    },
    "skus": [
      "SKU-00000275"
    ],
    "agreementId": 878,
    "status": "Submitted",
    "dateSubmitted": "2017-01-12T17:36:24",
    "dateCompleted": "",
    "statusDetail": "The request has been submitted for processing. Updated status should be available soon, usually within seconds."
  }
}