> ## 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 a Plug&Charge key

> Creates a Plug&Charge charging key for a user.



## OpenAPI

````yaml reference/openapi.json POST /drive/v1/users/{userId}/charging-keys/plug-and-charge
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/plug-and-charge:
    post:
      tags:
        - Charging Keys
      summary: Create a Plug&Charge key
      description: |-
        Creates a Plug&Charge charging key for a user. The key enables
        roaming authorization at PnC-capable charging stations.
      operationId: createPncChargingKey
      parameters:
        - name: userId
          in: path
          description: >-
            The unique identifier of the user who will own the new Plug&Charge
            key
          example: 6f36dc9b-446f-462b-aae0-95c7636d5c6c
          required: true
          schema:
            type: string
      requestBody:
        description: Plug&Charge key creation request
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChargingKeyPlugAndChargePostRequest'
            example:
              pcid: WDBRF61J21F123456
              contractId: DE-8PS-C0AD21B13-Q
        required: true
      responses:
        '200':
          description: Plug&Charge key created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChargingKeyPlugAndChargePostResponse'
              example:
                contractId: DE-8PS-C0AD21B13-Q
                pcid: WDBRF61J21F123456
                keyId: DE-8PS-C0AD21B13-Q
        '400':
          description: >-
            Invalid request. Possible causes: PCID or contractId syntactically
            incorrect, contractId prefix not allowed for organization or
            Plug&Charge feature not enabled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestErrorResponse'
              example:
                message: Invalid request payload
                fields:
                  - name: pcid
                    message: PCID must be 17-18 alphanumeric characters
                    rejectedValue: invalid
        '404':
          description: User not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: Resource not found
        '409':
          description: >-
            A charging key for this EMAID already exists (if EMAID-sharing is
            not allowed for the organization).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: A charging key for this EMAID already exists
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: Internal server error
      deprecated: false
      security:
        - ApiKeyAuth: []
components:
  schemas:
    ChargingKeyPlugAndChargePostRequest:
      title: ChargingKeyPlugAndChargePostRequest
      type: object
      required:
        - pcid
      properties:
        pcid:
          type: string
          example: VW123456789ABCDEFG
          description: >-
            identifies the vehicle and must correspond to the provisioning
            certificate
        contractId:
          type: string
          example: DE-8PS-CT4UN7OZ3-2
          description: >-
            Identifies the charging contract and is only accepted in EMA-ID
            format. Must correspond to the Plug and Charge contract certificate.
      description: Request payload to register a plug-and-charge contract identifier.
    ChargingKeyPlugAndChargePostResponse:
      type: object
      required:
        - contractId
        - pcid
        - keyId
      properties:
        contractId:
          type: string
          description: >-
            in EMA-ID format, must correspond to the Plug&Charge contract
            certificate.
        pcid:
          type: string
          description: >-
            Plug&Charge vehicle identifier (PCID). Is also used as referenceId
            of the charging key.
        keyId:
          type: string
          example: DE-8PS-CT4UN7OZ3-2
          description: >-
            Plug&Charge keys use the contractId (in EMA-ID format) as the
            keyIdentifier used for referencing in other endpoints
      description: Result payload after registering a Plug&Charge contract.
    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
  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.