{
  "openapi": "3.1.0",
  "info": {
    "title": "Locations API",
    "contact": {
      "email": "support@scurri.com"
    },
    "version": "2025.1",
    "description": "The Locations API provides eCommerce sellers with a list of delivery locations available\n at checkout. This allows customers to deliver their package to a location convenient \n to them.\n"
  },
  "servers": [
    {
      "url": "https://sandbox.scurri.co.uk/locations/api/company/{company_slug}/{service_slug}",
      "description": "The base URL for the Locations API",
      "variables": {
        "company_slug": {
          "default": "api-test-company",
          "description": "The slug of your company in Scurri."
        },
        "service_slug": {
          "default": "api-test-service",
          "description": "The slug of the service you want to retrieve locations for."
        }
      }
    }
  ],
  "tags": [
    {
      "name": "Locations",
      "description": "Locations related endpoints"
    }
  ],
  "paths": {
    "/delivery/": {
      "get": {
        "summary": "List Delivery Locations",
        "description": "Retrieve delivery locations for a service based on the given parameters:\n\n| Parameter      | Type   | Required | Description                                                                                 |\n|----------------|--------|------------|-------------------------------------------------------------------------------------------|\n| company_slug   | string | yes                  | The slug of your company in Scurri.                                             |\n| service_slug   | string | yes                  | The slug of the carrier service whose delivery locations are to be searched.    |\n| postcode       | string | no<sup>1</sup>       | The postcode being the epicentre of the search.                                 |\n| country        | string | no<sup>1</sup>       | The country of the postcode.                                                    |\n| latitude       | string | no<sup>2</sup>       | The latitude of the epicentre of the search.                                    |\n| longitude      | string | no<sup>2</sup>       | The longitude of the epicentre of the search.                                   |\n| radius         | string | no                   | The search radius in kilometers                                                 |\n| limit          | string | no                   | The maximum number of points returned.                                          |\n| categories     | array  | no                   | The categories of delivery locations to return. Accepts multiple values.        |\n\n<sup>1,2</sup> At least one set of the numbered parameters is required (either postcode+country or latitude+longitude).\n\n{% admonition type=\"warning\" name=\"IMPORTANT!\" %}\nTo trigger postcode-specific rules within [Delivery Options](https://docs.scurri.com/connect/delivery-options-api), you MUST use `postcode` and `country`. Coordinates (`latitude` / `longitude`) are not supported for evaluating these conditions.\n{% /admonition %}\n",
        "operationId": "getLocations",
        "tags": [
          "Locations"
        ],
        "parameters": [
          {
            "name": "postcode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The postcode to filter locations by. Acts as the epicenter of the search, from which locations will be returned based on the radius and limit specified\n",
            "example": "Y35 1X5"
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 20
            },
            "description": "The country of the postcode. Required if postcode is provided.\n",
            "example": "IE"
          },
          {
            "name": "latitude",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "format": "float",
              "minimum": -90,
              "maximum": 90
            },
            "example": 52.2,
            "description": "The latitude of the epicenter of the search. Required if longitude is provided.\n"
          },
          {
            "name": "longitude",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "format": "float",
              "minimum": -180,
              "maximum": 180
            },
            "example": -6.5,
            "description": "The longitude of the epicenter of the search. Required if latitude is provided.\n"
          },
          {
            "name": "radius",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "format": "float",
              "minimum": 0,
              "maximum": 50
            },
            "example": 10,
            "description": "The search radius in kilometers. Defaults to 10km if not specified.\n"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            },
            "example": 20,
            "description": "The maximum number of points to return. Defaults to 20 if not specified.\n"
          },
          {
            "name": "categories",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array"
            },
            "example": [
              "locker",
              "collection_point"
            ],
            "description": "The categories of delivery locations to return. Accepts multiple string values.\n"
          }
        ],
        "responses": {
          "200": {
            "description": "A list of delivery locations for the specified service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LocationsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "detail": {
                      "type": "string",
                      "description": "A description of the error",
                      "example": "Locations are not available for this service."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "You don't have permission to access this resource"
          }
        },
        "security": [
          {
            "basicAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "basicAuth": {
        "type": "apiKey",
        "name": "Authorization",
        "in": "header",
        "description": "All requests must be authenticated using Basic Auth. With Basic Auth, you have\nto send the username and password base64-encoded in the standard Basic manner,\ne.g. Authorization: Basic YXBpdGVzdDphcGkgcGFzc3dvcmQgdGVzdA==. Here is some\nsample code in Python to generate the value of the header:\n\n```python\n  >>> import base64\n  >>> username = 'apitest'\n  >>> password = 'api-test-password'\n  >>> base64.b64encode(f'{username}:{password}'.encode('ascii'))\n  b'YXBpdGVzdDphcGktdGVzdC1wYXNzd29yZA=='\n```\n"
      }
    },
    "schemas": {
      "Address": {
        "type": "object",
        "properties": {
          "address1": {
            "type": "string",
            "description": "The first line of the address",
            "example": "Innovation House"
          },
          "address2": {
            "type": "string",
            "description": "The second line of the address",
            "example": "The Bullring"
          },
          "address3": {
            "type": "string",
            "description": "The third line of the address",
            "example": ""
          },
          "city": {
            "type": "string",
            "description": "The city of the delivery location",
            "example": "Wexford"
          },
          "state": {
            "type": "string",
            "description": "The state or region of the delivery location",
            "example": "County Wexford"
          },
          "postcode": {
            "type": "string",
            "description": "The postcode of the delivery location",
            "example": "Y35 1X5"
          },
          "country": {
            "type": "string",
            "description": "The country of the delivery location",
            "example": "IE"
          }
        }
      },
      "OpeningHours": {
        "type": "object",
        "properties": {
          "day_of_week": {
            "type": "string",
            "description": "The day of the week",
            "enum": [
              "Monday",
              "Tuesday",
              "Wednesday",
              "Thursday",
              "Friday",
              "Saturday",
              "Sunday"
            ],
            "example": "Monday"
          },
          "open_from": {
            "type": "string",
            "description": "The opening time in 24-hour format",
            "example": "09:00"
          },
          "open_to": {
            "type": "string",
            "description": "The closing time in 24-hour format",
            "example": "17:00"
          }
        }
      },
      "DeliveryLocation": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The unique code for the delivery location",
            "example": "10"
          },
          "name": {
            "type": "string",
            "description": "The name of the delivery location",
            "example": "Wexford post office"
          },
          "type": {
            "type": "string",
            "description": "The type of the delivery location as assigned by the carrier",
            "example": "POL"
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "coordinates": {
            "type": "object",
            "properties": {
              "latitude": {
                "type": "number",
                "format": "float",
                "description": "The latitude of the delivery location",
                "example": 52.2
              },
              "longitude": {
                "type": "number",
                "format": "float",
                "description": "The longitude of the delivery location",
                "example": -6.5
              }
            }
          },
          "distance": {
            "type": "string",
            "description": "The distance from the epicenter of the search in kilometers",
            "example": "1.5"
          },
          "opening_hours": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OpeningHours"
            }
          },
          "carrier": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "The name of the carrier for the delivery location",
                "example": "Generic Carrier"
              },
              "logo": {
                "type": "string",
                "description": "The url of the carrier's logo",
                "example": "https://example.com/logo.png"
              }
            }
          },
          "category": {
            "type": "string",
            "description": "The category of the delivery location",
            "example": "collection_point"
          }
        }
      },
      "LocationsResponse": {
        "type": "object",
        "properties": {
          "delivery_locations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DeliveryLocation"
            }
          }
        }
      }
    }
  }
}