> ## Documentation Index
> Fetch the complete documentation index at: https://docs.loopreturns.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Location

> Create a new location.



## OpenAPI

````yaml post /locations
openapi: 3.1.0
info:
  title: Locations API
  description: >-
    API for managing locations


    ### Resource identifier format


    Resource identifiers (the `id` field and related global-identifier fields)
    are returned as JSON

    integers by default. To receive them as strings instead, send the

    `X-Loop-Global-Identifier-Type: string` request header.
  version: v1
servers:
  - url: https://api.loopreturns.com/api/v1
security: []
tags:
  - name: Locations
    description: Operations related to managing locations
paths:
  /locations:
    post:
      tags:
        - Locations
      summary: Create Location
      description: Create a new location.
      operationId: createLocation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateLocationRequest'
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LocationWrappedResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
      security:
        - write: []
components:
  schemas:
    CreateLocationRequest:
      type: object
      properties:
        external_id:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 64
          description: >-
            The provided `external_id` must be unique. If a non-unique
            `external_id` is provided, the API will respond with an error.
          examples:
            - 62291d16-9b61-4fbb-b868-21c2d32dc155
        sales_channel:
          type: string
          maxLength: 255
          examples:
            - shopify
          description: >-
            If a channel with this name is not already associated with the shop,
            it will be used to create a new channel.
        name:
          type: string
          maxLength: 100
          description: The name of the location.
          examples:
            - Main Warehouse
        status:
          type: string
          maxLength: 100
          description: The status of the location.
          enum:
            - active
            - inactive
        address:
          $ref: '#/components/schemas/AddressRequestData'
          description: The address of the location.
      required:
        - name
        - status
        - address
        - sales_channel
    LocationWrappedResponse:
      type: object
      required:
        - location
      properties:
        location:
          $ref: '#/components/schemas/LocationResponse'
    UnauthorizedResponse:
      type: object
      required:
        - errors
      properties:
        errors:
          type: string
          examples:
            - Unauthorized.
    ValidationErrorResponse:
      type: object
      description: >-
        Returned when the request body fails validation. Uses Laravel's standard
        validation error shape.
      properties:
        message:
          type: string
          examples:
            - The name field is required.
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          examples:
            - name:
                - The name field is required.
    AddressRequestData:
      type: object
      properties:
        name:
          type:
            - string
            - 'null'
          maxLength: 100
          description: The name of the address.
          examples:
            - Main Warehouse
        company:
          type:
            - string
            - 'null'
          maxLength: 100
          description: The name of the company residing at the address.
          examples:
            - Universal Exports
        address1:
          type: string
          maxLength: 125
          description: Line 1 of the address.
          examples:
            - 1234 Example Street
        address2:
          type:
            - string
            - 'null'
          maxLength: 125
          description: Line 2 of the address.
          examples:
            - Unit 19
        city:
          type: string
          maxLength: 100
          description: The city in which the address is located.
          examples:
            - Townsville
        region:
          type:
            - string
            - 'null'
          maxLength: 100
          description: The state or region in which the address is located.
          examples:
            - Louisiana
        postal_code:
          type:
            - string
            - 'null'
          maxLength: 16
          description: The postal code associated with the address.
          examples:
            - 90210
        country_code:
          type: string
          maxLength: 2
          description: The country code associated with the address.
          examples:
            - US
      required:
        - address1
        - city
        - country_code
    LocationResponse:
      type: object
      required:
        - id
        - sales_channel
        - name
        - status
        - address
      properties:
        id:
          type: integer
          format: int64
          description: The unique integer identifier for the location, created by Loop.
          examples:
            - 9007199254740991
        external_id:
          type:
            - string
            - 'null'
          description: The identifier used by an external source to identify the location.
          examples:
            - 62291d16-9b61-4fbb-b868-21c2d32dc155
        sales_channel:
          type: string
          description: The name of the channel.
          examples:
            - shopify
        name:
          type: string
          maxLength: 100
          description: The name of the location.
          examples:
            - Main Warehouse
        status:
          type: string
          description: The status of the location.
          enum:
            - active
            - inactive
        address:
          $ref: '#/components/schemas/AddressResponseData'
          description: The address of the location.
    AddressResponseData:
      type: object
      properties:
        name:
          type:
            - string
            - 'null'
          maxLength: 100
          description: The name of the address.
          examples:
            - Main Warehouse
        company:
          type:
            - string
            - 'null'
          maxLength: 100
          description: The name of the company residing at the address.
          examples:
            - Universal Exports
        address1:
          type:
            - string
            - 'null'
          maxLength: 125
          description: Line 1 of the address.
          examples:
            - 1234 Example Street
        address2:
          type:
            - string
            - 'null'
          maxLength: 125
          description: Line 2 of the address.
          examples:
            - Unit 19
        city:
          type:
            - string
            - 'null'
          maxLength: 100
          description: The city in which the address is located.
          examples:
            - Townsville
        region:
          type:
            - string
            - 'null'
          maxLength: 100
          description: The state or region in which the address is located.
          examples:
            - Louisiana
        postal_code:
          type:
            - string
            - 'null'
          maxLength: 16
          description: The postal code associated with the address.
          examples:
            - 90210
        country_code:
          type:
            - string
            - 'null'
          maxLength: 2
          description: The country code associated with the address.
          examples:
            - US
  securitySchemes:
    write:
      name: X-Authorization
      type: apiKey
      in: header
      description: 'API Scope: "Locations (write)"'

````