---
title: Batch import stops
description: Batch import stops. The request body must contain an array of stops
  to import. If the plan is not writable, the request will fail, prefer using
  the [Import Live Stops API](/api/live-stops/importLiveStops) instead.
url: /api/stops/importStops
---

# Batch import stops

`POST /plans/{planId}/stops:import`

````yaml
openapi: 3.1.0
info:
  title: Spoke API
  version: v1
servers:
  - url: https://api.spoke.com/public/v1
security:
  - BasicAuth: []
paths:
  /plans/{planId}/stops:import:
    post:
      operationId: importStops
      summary: Batch import stops
      tags:
        - Stops
      description: Batch import stops. The request body must contain an array of stops to import. If the plan is not writable, the request will fail, prefer using the [Import Live Stops API](/api/live-stops/importLiveStops) instead.
      requestBody:
        content:
          application/json:
            schema:
              minItems: 1
              maxItems: 100
              type: array
              items:
                type: object
                properties:
                  address:
                    type: object
                    properties:
                      addressName:
                        description: The name of the address. This will not be used for geocoding, and is only for the final address display purposes.
                        anyOf:
                          - type: string
                            minLength: 1
                            maxLength: 255
                          - type: "null"
                      addressLineOne:
                        description: The first line of the address.
                        anyOf:
                          - type: string
                            minLength: 1
                            maxLength: 255
                          - type: "null"
                      addressLineTwo:
                        description: The second line of the address.
                        anyOf:
                          - type: string
                            minLength: 1
                            maxLength: 255
                          - type: "null"
                      city:
                        description: The city of the address.
                        anyOf:
                          - type: string
                            minLength: 1
                            maxLength: 100
                          - type: "null"
                      state:
                        description: The state of the address.
                        anyOf:
                          - type: string
                            minLength: 1
                            maxLength: 100
                          - type: "null"
                      zip:
                        description: The zip code of the address.
                        anyOf:
                          - type: string
                            minLength: 1
                            maxLength: 100
                          - type: "null"
                      country:
                        description: The country of the address.
                        anyOf:
                          - type: string
                            minLength: 1
                            maxLength: 100
                          - type: "null"
                      latitude:
                        description: The latitude of the address in decimal degrees.
                        anyOf:
                          - type: number
                            minimum: -90
                            maximum: 90
                          - type: "null"
                      longitude:
                        description: The longitude of the address in decimal degrees.
                        anyOf:
                          - type: number
                            minimum: -180
                            maximum: 180
                          - type: "null"
                    additionalProperties: false
                    description: Address of the stop, at least one of the fields is required. If the latitude and longitude fields are set they will override any of the others. The addressName field is not used for geocoding and is only for display purposes.
                  recipient:
                    anyOf:
                      - type: object
                        properties:
                          externalId:
                            description: External ID of the recipient, as defined by the API user
                            anyOf:
                              - type: string
                                minLength: 1
                                maxLength: 255
                              - type: "null"
                          email:
                            description: The email address of the recipient. Multiple emails are not supported.
                            anyOf:
                              - type: string
                                maxLength: 255
                                format: email
                                pattern: ^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$
                              - type: "null"
                          phone:
                            description: Phone number of the recipient
                            anyOf:
                              - type: string
                                minLength: 1
                                maxLength: 255
                              - type: "null"
                          name:
                            description: Name of the recipient
                            anyOf:
                              - type: string
                                minLength: 1
                                maxLength: 255
                              - type: "null"
                        additionalProperties: false
                        description: Recipient information for this stop
                      - type: "null"
                  orderInfo:
                    anyOf:
                      - type: object
                        properties:
                          products:
                            description: Products in this stop
                            maxItems: 100
                            type: array
                            items:
                              type: string
                              minLength: 1
                              maxLength: 255
                          invoiceNumber:
                            description: Invoice number
                            anyOf:
                              - type: string
                                minLength: 1
                                maxLength: 255
                              - type: "null"
                          sellerOrderId:
                            description: Seller order ID
                            anyOf:
                              - type: string
                                minLength: 1
                                maxLength: 255
                              - type: "null"
                          sellerName:
                            description: Seller name
                            anyOf:
                              - type: string
                                minLength: 1
                                maxLength: 255
                              - type: "null"
                          sellerWebsite:
                            description: Seller website
                            anyOf:
                              - type: string
                                minLength: 1
                                maxLength: 255
                              - type: "null"
                        additionalProperties: false
                        description: Order information for this stop
                      - type: "null"
                  paymentOnDelivery:
                    anyOf:
                      - type: object
                        properties:
                          amount:
                            description: Amount *in minor units* (e.g. cents) to be collected upon delivery
                            anyOf:
                              - type: integer
                                minimum: 0
                                maximum: 9007199254740991
                              - type: "null"
                          currency:
                            description: Currency of the payment. Defaults to the team's currency.
                            anyOf:
                              - type: string
                                enum:
                                  - AED
                                  - ARS
                                  - AUD
                                  - BRL
                                  - CAD
                                  - CHF
                                  - CLP
                                  - CNY
                                  - COP
                                  - DKK
                                  - EGP
                                  - EUR
                                  - GBP
                                  - HKD
                                  - HUF
                                  - ILS
                                  - INR
                                  - JPY
                                  - KRW
                                  - MYR
                                  - MXN
                                  - NOK
                                  - NZD
                                  - PEN
                                  - RON
                                  - RUB
                                  - SAR
                                  - SEK
                                  - SGD
                                  - TRY
                                  - USD
                                  - UYU
                                  - ZAR
                              - type: "null"
                        additionalProperties: false
                        description: Payment on delivery (also known as "Cash on Delivery") data for this stop
                      - type: "null"
                  proofOfAttemptRequirements:
                    anyOf:
                      - type: object
                        properties:
                          enabled:
                            description: Whether proof of attempt is required for this stop
                            type:
                              - boolean
                              - "null"
                        additionalProperties: false
                        description: Proof of attempt requirement settings for this stop
                      - type: "null"
                  allowedDrivers:
                    description: Driver IDs that are allowed to be assigned to this stop. These drivers must be configured as part of the plan to be valid.
                    anyOf:
                      - maxItems: 100
                        type: array
                        items:
                          type: string
                          pattern: ^drivers\/[a-zA-Z0-9---_]{1,50}$
                      - type: "null"
                  activity:
                    default: delivery
                    description: Activity type
                    anyOf:
                      - type: string
                        enum:
                          - delivery
                          - pickup
                      - type: "null"
                  optimizationOrder:
                    description: The preferred order of this stop in the optimized route. If not provided or `"default"`, the stop will be placed in the optimal order, decided by the optimization algorithm. Otherwise it will be placed either `"first"` or `"last"`.
                    anyOf:
                      - type: string
                        enum:
                          - first
                          - last
                          - default
                      - type: "null"
                  packageCount:
                    description: Number of packages in the stop
                    anyOf:
                      - type: number
                        minimum: 1
                        maximum: 10000
                      - type: "null"
                  weight:
                    description: Weight information for this stop.
                    anyOf:
                      - type: object
                        properties:
                          amount:
                            type: number
                            minimum: 0
                            maximum: 999999
                            multipleOf: 0.01
                            description: The weight amount for this stop.
                          unit:
                            type: string
                            enum:
                              - kilogram
                              - pound
                              - metric-ton
                            description: The weight unit in which the amount is specified.
                        required:
                          - amount
                          - unit
                      - type: "null"
                  notes:
                    description: Notes for the stop
                    anyOf:
                      - type: string
                        minLength: 1
                        maxLength: 2000
                      - type: "null"
                  clientId:
                    description: Client ID of the retailer in Spoke Connect
                    anyOf:
                      - type: string
                        minLength: 1
                        maxLength: 100
                      - type: "null"
                  barcodes:
                    description: List of barcode IDs associated with this stop
                    maxItems: 200
                    type: array
                    items:
                      type: string
                      minLength: 1
                      maxLength: 255
                  customProperties:
                    description: Key-value pairs of custom stop properties for this stop. The keys must be unique and match a custom stop property defined in your team.
                    anyOf:
                      - type: object
                        propertyNames:
                          type: string
                          maxLength: 50
                          description: The custom stop property id
                        additionalProperties:
                          anyOf:
                            - type: string
                              minLength: 1
                              maxLength: 255
                            - type: "null"
                          description: The value of the custom stop property, up to 255 characters.
                      - type: "null"
                  serviceInfo:
                    anyOf:
                      - type: object
                        properties:
                          identifier:
                            anyOf:
                              - description: The identifier of a service offering to assign to this stop. Must match the identifier of a current, non-deleted service offering defined on your team. On update, set it to `null` to remove an assigned service; on create, omit it to leave the stop without a service.
                                type: string
                                minLength: 1
                                maxLength: 32
                                pattern: ^[a-zA-Z0-9]+$
                              - type: "null"
                          slaStartsAt:
                            anyOf:
                              - type: integer
                                exclusiveMinimum: 0
                                maximum: 9007199254740991
                                description: The SLA start time for this stop, in seconds since Unix epoch. Allows backdating when the actual order time is known. Can be provided with or without a service identifier.
                              - type: "null"
                        additionalProperties: false
                        description: Service offering data for this stop. Combines the service identifier and SLA start time. On update, set the whole object to `null` to clear all service info.
                      - type: "null"
                  timing:
                    anyOf:
                      - type: object
                        properties:
                          timeWindows:
                            description: Up to two ordered arrival windows for this stop. An empty array clears the windows. A single window may have one null bound; two windows must have both bounds set. Windows must not overlap or touch, and their total span must not exceed 24 hours.
                            type: array
                            maxItems: 2
                            items:
                              type: object
                              properties:
                                earliestAttemptTime:
                                  anyOf:
                                    - type: object
                                      properties:
                                        hour:
                                          type: integer
                                          minimum: 0
                                          maximum: 23
                                          description: Hour of the day
                                        minute:
                                          type: integer
                                          minimum: 0
                                          maximum: 59
                                          description: Minute of the hour
                                      required:
                                        - hour
                                        - minute
                                      additionalProperties: false
                                      description: Time of day in hours and minutes. Use a 24 hour clock.
                                    - type: "null"
                                  description: Earliest attempt time in this window. Null means there is no earliest time constraint. Both bounds must be non-null when providing two windows.
                                latestAttemptTime:
                                  anyOf:
                                    - type: object
                                      properties:
                                        hour:
                                          type: integer
                                          minimum: 0
                                          maximum: 23
                                          description: Hour of the day
                                        minute:
                                          type: integer
                                          minimum: 0
                                          maximum: 59
                                          description: Minute of the hour
                                      required:
                                        - hour
                                        - minute
                                      additionalProperties: false
                                      description: Time of day in hours and minutes. Use a 24 hour clock.
                                    - type: "null"
                                  description: Latest attempt time in this window. Null means there is no latest time constraint. Both bounds must be non-null when providing two windows.
                              required:
                                - earliestAttemptTime
                                - latestAttemptTime
                              additionalProperties: false
                          earliestAttemptTime:
                            description: Time of day of the earliest time this stop should happen
                            anyOf:
                              - type: object
                                properties:
                                  hour:
                                    type: integer
                                    minimum: 0
                                    maximum: 23
                                    description: Hour of the day
                                  minute:
                                    type: integer
                                    minimum: 0
                                    maximum: 59
                                    description: Minute of the hour
                                required:
                                  - hour
                                  - minute
                                additionalProperties: false
                                description: Time of day in hours and minutes. Use a 24 hour clock.
                              - type: "null"
                          latestAttemptTime:
                            description: Time of day of the latest time this stop should happen
                            anyOf:
                              - type: object
                                properties:
                                  hour:
                                    type: integer
                                    minimum: 0
                                    maximum: 23
                                    description: Hour of the day
                                  minute:
                                    type: integer
                                    minimum: 0
                                    maximum: 59
                                    description: Minute of the hour
                                required:
                                  - hour
                                  - minute
                                additionalProperties: false
                                description: Time of day in hours and minutes. Use a 24 hour clock.
                              - type: "null"
                          estimatedAttemptDuration:
                            description: Duration in seconds of the activity in this stop, only set if you want to override the default. This can be set up to 8 hours.
                            anyOf:
                              - type: integer
                                minimum: 1
                                maximum: 28800
                              - type: "null"
                        additionalProperties: false
                      - type: "null"
                required:
                  - address
                additionalProperties: false
              description: An array of stops to import in batch. Supports a maximum of 100 stops per request.
        description: An array of stops to import in batch. Supports a maximum of 100 stops per request.
      parameters:
        - schema:
            type: string
            pattern: ^[a-zA-Z0-9---_]{1,50}$
          in: path
          name: planId
          required: true
          description: The plan id
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: array
                    items:
                      type: string
                      pattern: ^plans\/[a-zA-Z0-9---_]{1,50}\/stops\/[a-zA-Z0-9---_]{1,50}$
                      description: The id of the stop, in the format `plans/<id>/stops/<id>`.
                    description: The ids of the successfully imported stops
                  failed:
                    type: array
                    items:
                      type: object
                      properties:
                        error:
                          type: object
                          properties:
                            message:
                              type: string
                              description: The error that occurred during import
                            code:
                              type: string
                              description: Stable error code
                            param:
                              type: string
                              description: Invalid request parameter
                          required:
                            - message
                        stop:
                          type: object
                          properties:
                            address:
                              type: object
                              properties:
                                addressName:
                                  anyOf:
                                    - type: string
                                      minLength: 1
                                      maxLength: 255
                                    - type: "null"
                                  description: The name of the address. This will not be used for geocoding, and is only for the final address display purposes.
                                addressLineOne:
                                  anyOf:
                                    - type: string
                                      minLength: 1
                                      maxLength: 255
                                    - type: "null"
                                  description: The first line of the address.
                                addressLineTwo:
                                  anyOf:
                                    - type: string
                                      minLength: 1
                                      maxLength: 255
                                    - type: "null"
                                  description: The second line of the address.
                                city:
                                  anyOf:
                                    - type: string
                                      minLength: 1
                                      maxLength: 100
                                    - type: "null"
                                  description: The city of the address.
                                state:
                                  anyOf:
                                    - type: string
                                      minLength: 1
                                      maxLength: 100
                                    - type: "null"
                                  description: The state of the address.
                                zip:
                                  anyOf:
                                    - type: string
                                      minLength: 1
                                      maxLength: 100
                                    - type: "null"
                                  description: The zip code of the address.
                                country:
                                  anyOf:
                                    - type: string
                                      minLength: 1
                                      maxLength: 100
                                    - type: "null"
                                  description: The country of the address.
                                latitude:
                                  anyOf:
                                    - type: number
                                      minimum: -90
                                      maximum: 90
                                    - type: "null"
                                  description: The latitude of the address in decimal degrees.
                                longitude:
                                  anyOf:
                                    - type: number
                                      minimum: -180
                                      maximum: 180
                                    - type: "null"
                                  description: The longitude of the address in decimal degrees.
                              required:
                                - addressName
                                - addressLineOne
                                - addressLineTwo
                                - city
                                - state
                                - zip
                                - country
                                - latitude
                                - longitude
                              additionalProperties: false
                              description: The address of the stop that failed to import
                            recipient:
                              anyOf:
                                - type: object
                                  properties:
                                    externalId:
                                      anyOf:
                                        - type: string
                                          minLength: 1
                                          maxLength: 255
                                        - type: "null"
                                      description: External ID of the recipient, as defined by the API user
                                    email:
                                      anyOf:
                                        - type: string
                                          maxLength: 255
                                          format: email
                                          pattern: ^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$
                                        - type: "null"
                                      description: The email address of the recipient. Multiple emails are not supported.
                                    phone:
                                      anyOf:
                                        - type: string
                                          minLength: 1
                                          maxLength: 255
                                        - type: "null"
                                      description: Phone number of the recipient
                                    name:
                                      anyOf:
                                        - type: string
                                          minLength: 1
                                          maxLength: 255
                                        - type: "null"
                                      description: Name of the recipient
                                  required:
                                    - externalId
                                    - email
                                    - phone
                                    - name
                                  additionalProperties: false
                                - type: "null"
                              description: The recipient of the stop that failed to import
                          required:
                            - address
                            - recipient
                          description: The stop that failed to import
                      required:
                        - error
                        - stop
                    description: The failed stops
                required:
                  - success
                  - failed
                description: Success
        "400":
          description: The request has errors. Either syntactic or semantic
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: The error message.
                  code:
                    type: string
                    description: The error code.
                  param:
                    type: string
                    description: The parameter that caused the error.
                  url:
                    type: string
                    description: The URL with more information about the error.
                required:
                  - message
                description: The request has errors. Either syntactic or semantic
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: The error message.
                  url:
                    type: string
                    description: The URL with more information about the error.
                required:
                  - message
                description: Unauthorized
        "403":
          description: The plan is no longer accessible or one or more stops contain fields that require upgrading your team subscription.
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      message:
                        type: string
                        enum:
                          - Plan is no longer accessible due to data access restrictions. Upgrade to a plan that supports a longer delivery history period to access it.
                      code:
                        type: string
                        enum:
                          - plan_inaccessible
                      url:
                        type: string
                        enum:
                          - https://dispatch.spoke.com/paywall
                    required:
                      - message
                      - code
                      - url
                    description: Plan is no longer accessible due to data access restrictions. Upgrade to a plan that supports a longer delivery history period to access it.
                    x-response-description: Plan is no longer accessible due to data access restrictions. Upgrade to a plan that supports a longer delivery history period to access it.
                  - type: object
                    properties:
                      message:
                        type: string
                        description: The error message.
                      code:
                        type: string
                        enum:
                          - feature_not_in_subscription
                      url:
                        type: string
                        enum:
                          - https://dispatch.spoke.com/paywall
                    required:
                      - message
                      - code
                      - url
                    description: Feature not included in your team subscription
                description: The plan is no longer accessible or one or more stops contain fields that require upgrading your team subscription.
        "404":
          description: A plan or a driver was not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: The error message.
                required:
                  - message
                description: A plan or a driver was not found
        "409":
          description: The plan is not writable.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    enum:
                      - Plan is not writable
                  code:
                    type: string
                    enum:
                      - plan_not_writable
                required:
                  - message
                  - code
                description: The plan is not writable.
                title: Plan is not writable
        "410":
          description: Failed to create stop
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    enum:
                      - Failed to create stop. Some related resources were deleted while the request was being processed.
                required:
                  - message
                description: Failed to create stop
        "412":
          description: Drivers must be part of the plan to be referenced by stops
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    enum:
                      - Driver is not linked to plan
                  param:
                    type: string
                    description: The parameter that caused the error.
                required:
                  - message
                description: Drivers must be part of the plan to be referenced by stops
                title: Driver is not linked to plan
        "422":
          description: The stop is unprocessable.
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      message:
                        anyOf:
                          - type: string
                            enum:
                              - An error occurred when creating the stop, but the error is not due to a validation error, instead it is another conflict, check if the provided data is semantically valid.
                          - type: string
                    required:
                      - message
                    description: Failed to create stop
                  - type: object
                    properties:
                      message:
                        type: string
                        description: The error message.
                      code:
                        type: string
                        enum:
                          - vehicle_capacity_disabled
                      url:
                        type: string
                        enum:
                          - https://dispatch.spoke.com/settings/team-profile
                    required:
                      - message
                      - code
                      - url
                    description: Vehicle capacity mode is disabled in the team's settings
                description: The stop is unprocessable.
        "500":
          description: An internal server error occurred
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: The error message.
                  code:
                    type: string
                    description: The error code.
                  param:
                    type: string
                    description: The parameter that caused the error.
                  url:
                    type: string
                    description: The URL with more information about the error.
                required:
                  - message
                description: An internal server error occurred
        default:
          description: The default error model
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: The error message.
                  code:
                    type: string
                    description: The error code.
                  param:
                    type: string
                    description: The parameter that caused the error.
                  url:
                    type: string
                    description: The URL with more information about the error.
                required:
                  - message
                description: The default error model
components:
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
      description: Use the API key as the username and leave the password empty.
````