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

# Get code history for multiple devices

> Return the decrypted code history (recovery key, iCloud bypass code, unlock PIN, recovery OS password) for MULTIPLE devices in one call, grouped by device id, each newest first. Provide a list of `deviceIds` (up to 200 per call), optionally filtered by `type`. Devices that do not exist, or that do not belong to your company, are returned with an empty `data` array. Prefer this over calling `getDeviceCodeHistory` once per device.

<span className="badge-read">Key: Read</span><span className="badge-company">Scope: Company</span>


## OpenAPI

````yaml https://api.getprimo.com/openapi.json post /devices/code-history
openapi: 3.1.1
info:
  title: Public API - BETA
  description: Read docs on https://docs.getprimo.com/
  version: '1.0'
  contact: {}
servers:
  - url: https://api.getprimo.com
security:
  - apikey: []
tags: []
paths:
  /devices/code-history:
    post:
      tags:
        - Devices
      summary: Get code history for multiple devices
      description: >-
        Return the decrypted code history (recovery key, iCloud bypass code,
        unlock PIN, recovery OS password) for MULTIPLE devices in one call,
        grouped by device id, each newest first. Provide a list of `deviceIds`
        (up to 200 per call), optionally filtered by `type`. Devices that do not
        exist, or that do not belong to your company, are returned with an empty
        `data` array. Prefer this over calling `getDeviceCodeHistory` once per
        device.
      operationId: getDevicesCodeHistory
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetDevicesCodeHistoryBody'
      responses:
        default:
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetDevicesCodeHistory_Output'
components:
  schemas:
    GetDevicesCodeHistoryBody:
      type: object
      properties:
        deviceIds:
          description: Device ids to fetch code history for. Up to 200 per call.
          minItems: 1
          maxItems: 200
          type: array
          items:
            type: string
        type:
          description: >-
            Optional filter: ICLOUD_BYPASS_CODE, UNLOCK_PIN, RECOVERY_KEY, or
            RECOVERY_OS.
          type: string
          enum:
            - ICLOUD_BYPASS_CODE
            - UNLOCK_PIN
            - RECOVERY_KEY
            - RECOVERY_OS
      required:
        - deviceIds
    GetDevicesCodeHistory_Output:
      type: object
      properties:
        items:
          type: array
          description: Code history grouped by device id.
          items:
            type: object
            properties:
              deviceId:
                type: string
              data:
                description: >-
                  Code history entries for this device, newest first. Empty when
                  the device has no history, does not exist, or does not belong
                  to your company.
                type: array
                items:
                  type: object
                  properties:
                    type:
                      description: >-
                        Type of code: ICLOUD_BYPASS_CODE, UNLOCK_PIN,
                        RECOVERY_KEY, or RECOVERY_OS.
                      type: string
                      enum:
                        - ICLOUD_BYPASS_CODE
                        - UNLOCK_PIN
                        - RECOVERY_KEY
                        - RECOVERY_OS
                    code:
                      description: Decrypted code value.
                      type: string
                    createdAt:
                      type: string
                      format: date-time
                      pattern: >-
                        ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                  required:
                    - type
                    - code
                    - createdAt
                  additionalProperties: false
            required:
              - deviceId
              - data
            additionalProperties: false
      required:
        - items
      additionalProperties: false
  securitySchemes:
    apikey:
      scheme: bearer
      bearerFormat: API key
      type: http
      description: >-
        Use your Primo API key in the Authorization header as `Bearer
        <API_KEY>`.

````