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

# Calculate distance to a location



## OpenAPI

````yaml /generated/storefront.openapi.json post /locations/{locationId}/distance
openapi: 3.0.3
info:
  title: Crave Storefront API
  version: 2.0.0
  description: >-
    Direct public Storefront API. Anonymous catalog reads require no API key.
    Protected resources use purpose-limited cart, checkout, receipt, or customer
    credentials.
  contact:
    name: Crave Support
    email: hello@craveup.com
servers:
  - url: https://api.craveup.com/api/v1/storefront
    description: Production Storefront API
  - url: https://dev-api-43233223.craveup.com/api/v1/storefront
    description: Sandbox Storefront API
security: []
tags:
  - name: Merchants
  - name: Locations
  - name: Ordering Sessions
  - name: Menus
  - name: Products
  - name: Analytics
  - name: Carts
  - name: Checkout
  - name: Cart Items
  - name: Discounts
  - name: Loyalty
  - name: Customer Authentication
  - name: Customers
  - name: Orders
paths:
  /locations/{locationId}/distance:
    post:
      tags:
        - Locations
      summary: Calculate distance to a location
      operationId: storefrontCalculateLocationDistance
      parameters:
        - name: locationId
          in: path
          required: true
          schema:
            type: string
            minLength: 1
            maxLength: 128
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DistanceRequest'
      responses:
        '200':
          description: Distance calculation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DistanceResponse'
        '400':
          description: The request is invalid.
          headers:
            X-Request-Id:
              description: Opaque request identifier for support and telemetry correlation.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommerceErrorEnvelope'
        '404':
          description: The requested resource was not found.
          headers:
            X-Request-Id:
              description: Opaque request identifier for support and telemetry correlation.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommerceErrorEnvelope'
        '429':
          description: The request was rate limited.
          headers:
            X-Request-Id:
              description: Opaque request identifier for support and telemetry correlation.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommerceErrorEnvelope'
        '500':
          description: An unexpected error occurred.
          headers:
            X-Request-Id:
              description: Opaque request identifier for support and telemetry correlation.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommerceErrorEnvelope'
        '503':
          description: A required dependency is temporarily unavailable.
          headers:
            X-Request-Id:
              description: Opaque request identifier for support and telemetry correlation.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommerceErrorEnvelope'
      security: []
components:
  schemas:
    DistanceRequest:
      type: object
      properties:
        lat:
          type: number
          minimum: -90
          maximum: 90
        lng:
          type: number
          minimum: -180
          maximum: 180
        unit:
          default: miles
          type: string
          enum:
            - miles
            - kilometers
      required:
        - lat
        - lng
      additionalProperties: false
    DistanceResponse:
      type: object
      properties:
        locationId:
          type: string
          minLength: 1
          maxLength: 128
        location:
          type: object
          properties:
            id:
              type: string
              minLength: 1
              maxLength: 128
            restaurantDisplayName:
              type: string
            addressString:
              type: string
            coordinates:
              type: object
              properties:
                lat:
                  type: number
                lng:
                  type: number
              required:
                - lat
                - lng
              additionalProperties: false
          required:
            - id
            - restaurantDisplayName
            - addressString
            - coordinates
          additionalProperties: {}
        distance:
          type: object
          properties:
            value:
              type: number
              minimum: 0
            unit:
              type: string
              enum:
                - miles
                - kilometers
            miles:
              type: number
              minimum: 0
            kilometers:
              type: number
              minimum: 0
          required:
            - value
            - unit
            - miles
            - kilometers
          additionalProperties: false
      required:
        - locationId
        - location
        - distance
      additionalProperties: false
    CommerceErrorEnvelope:
      type: object
      properties:
        code:
          anyOf:
            - type: string
              enum:
                - VALIDATION_ERROR
                - UNAUTHORIZED
                - FORBIDDEN
                - NOT_FOUND
                - RATE_LIMITED
                - CART_CONFLICT
                - RESOURCE_CONFLICT
                - CART_IMMUTABLE
                - IDEMPOTENCY_KEY_REQUIRED
                - IDEMPOTENCY_KEY_REUSED
                - IDEMPOTENCY_IN_PROGRESS
                - DEPENDENCY_UNAVAILABLE
                - INTERNAL_ERROR
            - type: string
              minLength: 1
        message:
          type: string
          minLength: 1
        requestId:
          type: string
          minLength: 8
        details:
          type: object
          additionalProperties: {}
      required:
        - code
        - message
        - requestId
      additionalProperties: false

````