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

# Add a card

> Adds a card to a location you reach with sensitive access or more, so it charges at the
location's chargers, or only at those in `charger_ids`. It counts from the next card check a
charger asks for. An id another card at the location has, in any case, is refused (`taken`).



## OpenAPI

````yaml api-reference/v4/v4.openapi.json POST /locations/{location}/cards
openapi: 3.1.0
info:
  title: Plugchoice API
  description: >-
    Every request sends an access token as `Authorization: Bearer …`, unless an
    operation says otherwise.


    Errors are problems (RFC 9457, `application/problem+json`): `code` says what
    went wrong, and a failed validation lists the fields in `errors`.


    A list answers one page: `{"data": [...], "next_cursor": ...,
    "previous_cursor": ...}`. Pass a cursor back as `cursor` to get that page,
    and `limit` (1 to 100, default 25) for its size.


    Within v4, changes only add: new operations, new optional parameters, new
    fields and new enum values. Ignore fields you do not know, and accept enum
    values you do not know. Requests that send a field the operation does not
    know are refused, so a typo does not pass unnoticed.
  version: '4'
servers:
  - url: https://api.plugchoice.com/v4
security:
  - bearer: []
paths:
  /locations/{location}/cards:
    post:
      tags:
        - cards
      summary: Add a card
      description: >-
        Adds a card to a location you reach with sensitive access or more, so it
        charges at the

        location's chargers, or only at those in `charger_ids`. It counts from
        the next card check a

        charger asks for. An id another card at the location has, in any case,
        is refused (`taken`).
      operationId: create_location_card
      parameters:
        - name: location
          in: path
          description: The location's id
          required: true
          schema:
            type: string
            format: uuid
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCard'
        required: true
      responses:
        '201':
          description: The card, added
          headers:
            Idempotent-Replayed:
              $ref: '#/components/headers/IdempotentReplayed'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChargeCard'
        default:
          description: >-
            A problem (RFC 9457). `code` says which; the field errors come with
            `validation-failed`.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
      security:
        - bearer:
            - locations:write
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      description: >-
        Makes the request safe to retry: a key of your choice, new for each
        request, such as a UUID. A retry with the same key, method, path and
        body within 24 hours gets the first answer again, with
        `Idempotent-Replayed: true`, and changes nothing. The same key with
        another request is refused (`idempotency-key-reused`), and a retry while
        the first request is still running is a `conflict`. A request that
        failed stored nothing, so its retry runs again. Keys are your own:
        another client, or another person, may use the same key.
      required: false
      schema:
        type: string
        maxLength: 255
        minLength: 1
        pattern: ^[\x21-\x7E]+$
  schemas:
    CreateCard:
      type: object
      description: A new card.
      required:
        - name
        - id_tag
      properties:
        billed:
          type: boolean
          description: Whether it is billed through roaming instead of charging free.
          default: false
        charger_ids:
          type: array
          items:
            type: string
            format: uuid
          description: >-
            The chargers at the location it may charge at; left out or empty:
            every charger at the

            location.
        id_tag:
          $ref: '#/components/schemas/IdTag'
        name:
          $ref: '#/components/schemas/Name'
          description: 'Its name, as people know it: `Jan''s car`.'
      additionalProperties: false
    ChargeCard:
      type: object
      description: >-
        A charge card of a location: a card, or another token such as a phone's,
        that may charge at

        the location's chargers.
      required:
        - id
        - name
        - id_tag
        - automatic
        - billed
        - charger_ids
      properties:
        automatic:
          type: boolean
          description: >-
            Whether Plugchoice made it for the location, so a charger at home
            charges without anyone

            adding a card: Autostart and a start from the app use it. There is
            no physical card; it is

            changed and removed like any other.
        billed:
          type: boolean
          description: Whether it is billed through roaming instead of charging free.
        charger_ids:
          type: array
          items:
            type: string
            format: uuid
          description: >-
            The chargers at the location it may charge at; empty: every charger
            at the location.
        created_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When it was added; null for a card from before Plugchoice recorded
            it.
        id:
          type: string
          format: uuid
          description: The card's id.
        id_tag:
          type: string
          description: >-
            The id it shows a charger (OCPP's idTag or idToken). The card check
            compares it ignoring

            case.
        name:
          type: string
          description: 'Its name, as people know it: `Jan''s car`.'
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            When it, or the chargers it may charge at, last changed; null for a
            card from before

            Plugchoice recorded it.
    Problem:
      type: object
      description: An error response body (RFC 9457).
      required:
        - type
        - title
        - status
        - code
      properties:
        code:
          type: string
          description: 'The kind of problem, for code to act on: the last part of `type`.'
        detail:
          type: string
          description: >-
            What went wrong with this request, when there is more to say than
            the title.
        errors:
          type: array
          items:
            $ref: '#/components/schemas/FieldError'
          description: 'With `validation-failed`: the fields that broke a rule.'
        status:
          type: integer
          format: int32
          description: The HTTP status code.
          minimum: 0
        title:
          type: string
          description: A short summary of the kind of problem.
        type:
          type: string
          description: The page that explains this kind of problem.
    IdTag:
      type: string
      description: >-
        The id a card shows a charger (OCPP's idTag or idToken), such as
        `04A2B334A1C380`: 1 to 36 characters (the longest an OCPP 2.0.1 charger
        reads; 20 for OCPP 1.6), with spaces around it removed. The card check
        compares it ignoring case, so `ab12` and `AB12` are one card.
      maxLength: 36
      minLength: 1
    Name:
      type: string
      description: >-
        A name people give something (a location, a charger, a team): 1 to 255
        characters, with spaces around it removed.
      maxLength: 255
      minLength: 1
    FieldError:
      type: object
      description: One field that broke a rule.
      required:
        - field
        - code
        - message
      properties:
        code:
          type: string
          description: >-
            The rule it broke, for code to act on: `missing-field`,
            `unknown-field`, `invalid-type`,

            `invalid`, or `taken` (a value that must be unique, such as a card's
            id at a location,

            and is not).
        field:
          type: string
          description: >-
            Where the field is in the request, such as `name` or
            `connectors[0].max_current`.
        message:
          type: string
          description: What is wrong, in English.
  headers:
    IdempotentReplayed:
      schema:
        type: string
        enum:
          - 'true'
      description: >-
        `true` on an answer given again for a request with the same
        `Idempotency-Key`.
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        An access token from `accounts.plugchoice.com`, for a personal API
        token, a person signed in through an app, or an OAuth client.

````

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