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

# Create charging key order

> Orders a charging key for the given user. Requires the product to be configured on Plugsurfing side. Therefore, we ask you to reach out to us before using it.



## OpenAPI

````yaml reference/openapi.json POST /drive/v1/users/{userId}/charging-keys/orders
openapi: 3.1.0
info:
  title: Drive API
  version: 1.0.0
  description: >-
    The Drive API provides comprehensive access to Plugsurfing's charging
    infrastructure network. It enables you to manage users, charging keys,
    search for charging locations, handle payments, and control charging
    sessions.
servers:
  - url: https://{environment}.plugsurfing.com
    variables:
      environment:
        enum:
          - drive-api-stage
        default: drive-api-stage
        description: >-
          API environment - use drive-api-stage for testing and drive-api for
          production
security: []
tags:
  - name: Geosearch
    description: >-
      Search and retrieve detailed information about charging locations and
      stations
  - name: Users
    description: >-
      Manage user accounts including creation, retrieval, updates, and deletion.
      Handles user-specific data and preferences.
  - name: Charging Keys
    description: >-
      Manage physical and virtual charging keys including creation, activation,
      updates, and status management. Essential for user access to charging
      stations.
  - name: Sessions
    description: >-
      Access and manage charging session data including history, status, and
      detailed session information
  - name: Remote Charging
    description: >-
      Control charging sessions remotely including starting and stopping
      sessions, and monitoring session status
  - name: Payment Options
    description: >-
      Manage payment methods and handle transaction processing for charging
      services
  - name: User Groups
    description: Manage user group memberships
  - name: Vouchers
    description: Redeem vouchers
  - name: Charging Key Orders
    description: Handle the ordering and fulfillment process for physical charging keys
  - name: EMP Charging Keys
    description: E-Mobility Provider specific endpoints for managing charging keys
  - name: EMP Geosearch
    description: E-Mobility Provider specific endpoints for location search and information
  - name: EMP Orders
    description: E-Mobility Provider specific endpoints for managing orders
  - name: EMP Sessions
    description: E-Mobility Provider specific endpoints for managing charging sessions
  - name: EMP Fleets
    description: E-Mobility Provider specific endpoints for managing fleets
paths:
  /drive/v1/users/{userId}/charging-keys/orders:
    post:
      tags:
        - Charging Key Orders
      summary: Create charging key order
      description: >-
        Orders a charging key for the given user. Requires the product to be
        configured on Plugsurfing side. Therefore, we ask you to reach out to us
        before using it.
      operationId: createChargingKeyOrder
      parameters:
        - name: userId
          in: path
          example: 6f36dc9b-446f-462b-aae0-95c7636d5c6c
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChargingKeyOrderRequest'
            example:
              productId: physical-rfid-key
              quantity: 1
              address:
                line1: Kungsgatan 1
                line2: Floor 2
                city: Stockholm
                postalCode: '11143'
                countryCode: SE
                firstName: Olivier
                lastName: Payen
                company: Plugsurfing
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChargingKeyOrderResponse'
              example:
                id: 9aE20Rmj0v
                state: ORDER_PLACED
                clientSecret: pi_1J5J9v3sZvKYlo2C5J9v2eZv
        '400':
          description: The provided query parameters, route parameters or body is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestErrorResponse'
              example:
                message: Invalid request payload
                details:
                  - field X is required
        '404':
          description: User not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: Resource not found
        '429':
          description: >-
            Too many requests — a given user can't order more than 1 card every
            5 minutes.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: Resource not found
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: Resource not found
      deprecated: false
      security:
        - ApiKeyAuth: []
components:
  schemas:
    ChargingKeyOrderRequest:
      title: ChargingKeyOrderRequest
      description: >-
        This endpoint allows you to order a charging key for a specific user. To
        prevent duplicate orders, ordering charging keys for a single user is
        throttled to 1 order every 5 minutes. This is a safety measure to avoid
        accidental double-clicks on the order button, preventing the user from
        being charged twice. If the user exceeds this limit, a `429 - Too Many
        Requests` HTTP response will be returned.
      type: object
      required:
        - address
        - taxationCountry
      properties:
        address:
          $ref: '#/components/schemas/ChargingKeyOrderAddressRequest'
          description: Shipping address for the ordered charging key.
        taxationCountry:
          type: string
          maxLength: 2
          example: SE
          description: Two-letter taxation country code
        paymentOptionId:
          type: string
          example: STRIPE-6738556949187507
          description: Stripe payment option id. If not passed, a default one is used.
      example:
        taxationCountry: SE
        paymentOptionId: STRIPE-6738556949187507
        address:
          addressLine1: Test, don't send
          postalCode: 01-111
          city: Test
          country: PL
          firstName: Will
          lastName: Smith
          companyName: Plugsurfing
    ChargingKeyOrderResponse:
      title: ChargingKeyOrderResponse
      type: object
      required:
        - id
        - state
      properties:
        id:
          type: string
          example: 9aE20Rmj0v
          description: Unique identifier of the created charging key order.
        state:
          $ref: '#/components/schemas/OrderState'
          description: Current lifecycle state of the charging key order.
        clientSecret:
          type: string
          example: pi_1J5J9v3sZvKYlo2C5J9v2eZv
          description: >-
            If Stripe payment requires a 3DS authentication, this field will be
            populated with the clientSecret from Stripe, which should be sent
            back to client side Stripe SDK for user authentication.
      description: Result returned after creating a charging key order.
    InvalidRequestErrorResponse:
      title: InvalidRequestErrorResponse
      type: object
      required:
        - message
        - fields
      properties:
        message:
          type: string
        fields:
          type: array
          items:
            title: InvalidField
            type: object
            required:
              - name
              - message
              - rejectedValue
            properties:
              name:
                type: string
              message:
                type: string
                example: UserId is not correct
              rejectedValue:
                type: string
    ErrorResponse:
      title: ErrorResponse
      type: object
      properties:
        message:
          type: string
    ChargingKeyOrderAddressRequest:
      title: ChargingKeyOrderAddressRequest
      type: object
      required:
        - addressLine1
        - postalCode
        - city
        - country
      properties:
        companyName:
          type: string
          maxLength: 130
          example: Plugsurfing
          description: Company name for business delivery addresses.
        firstName:
          type: string
          maxLength: 130
          example: John
          description: Recipient first name.
        lastName:
          type: string
          maxLength: 130
          example: Drive
          description: Recipient last name.
        addressLine1:
          type: string
          minLength: 1
          maxLength: 100
          example: Automation road 1
          description: Primary street address line.
        addressLine2:
          type: string
          example: Park spot 1
          description: Secondary address line such as apartment or suite.
        postalCode:
          type: string
          minLength: 1
          maxLength: 10
          example: EV1234
          description: Postal or ZIP code.
        city:
          type: string
          minLength: 1
          maxLength: 50
          example: Spark City
          description: City name.
        country:
          type: string
          minLength: 1
          maxLength: 41
          example: SE
          description: Country code in ISO 3166-1 alpha-2 format.
      description: Shipping address used when placing a charging key order.
    OrderState:
      type: string
      enum:
        - ORDER_FILLED
        - ORDER_CANCELLED
        - ORDER_PROCESSING
        - ORDER_WAITING_3DS
        - ORDER_PAYMENT_FAILED
        - ORDER_REFUND_FAILED
        - ORDER_REFUNDED
        - ORDER_PLACED
        - ORDER_PAID
      example: ORDER_PLACED
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.