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

# Create a Shared Secret for a Device

> Creates a new key and secret the device can connect with. The secret is returned once, in this response, and cannot be retrieved again. Returns unprocessable entity when device shared secrets are not enabled on this platform.



## OpenAPI

````yaml https://manage.nervescloud.com/api/openapi post /api/orgs/{org_name}/products/{product_name}/devices/{identifier}/shared_secrets
openapi: 3.0.0
info:
  description: >
    The NervesCloud API gives users full access to their

    Orgs, Products, and corresponding Device fleets.


    The API can be used to integrate with your own systems, providing full
    access to your Product and Device data.


    The API is documented using the OpenAPI 3.0 specification.
  title: NervesCloud API
  version: 2.0.0
servers:
  - url: https://manage.nervescloud.com
    variables: {}
security:
  - bearer_auth: []
tags:
  - description: Archive uploading and downloading
    name: Archives
  - description: User authentication and API token creation
    name: Auth
  - description: Organization Certificate Authority management
    name: CA Certificates
  - description: >-
      Device management, including action requests eg. upgrade, reboot,
      reconnect
    name: Devices
  - description: Log lines Devices have sent over the logging extension
    name: Device Logs
  - description: Metric history Devices have reported over the health or metrics extension
    name: Device Metrics
  - description: >-
      Device management, including action requests eg. upgrade, reboot,
      reconnect
    name: Devices (short URL)
  - description: Device Certificate management
    name: Device Certificates
  - description: Keys and secrets a Device can connect with instead of a certificate
    name: Device Shared Secrets
  - description: Identities a Device holds on networks NervesHub does not run
    name: Network Identities
  - description: Deployment Group and release management
    name: Deployment Groups
  - description: Firmware uploading and management
    name: Firmwares
  - description: Organization iroh endpoint id registration
    name: Iroh Endpoints
  - description: Organization management
    name: Organizations
  - description: Organization User membership management
    name: Organization Members
  - description: Product management
    name: Products
  - description: Organization Signing Key management
    name: Signing Keys
  - description: Product Support Script management
    name: Support Scripts
  - description: Endpoints an Organization sends its Products' Device events to
    name: Webhooks
  - description: Platform healthcheck
    name: Platform Status
paths:
  /api/orgs/{org_name}/products/{product_name}/devices/{identifier}/shared_secrets:
    post:
      tags:
        - Device Shared Secrets
      summary: Create a Shared Secret for a Device
      description: >-
        Creates a new key and secret the device can connect with. The secret is
        returned once, in this response, and cannot be retrieved again. Returns
        unprocessable entity when device shared secrets are not enabled on this
        platform.
      operationId: NervesHubWeb.API.DeviceSharedSecretController.create
      parameters:
        - description: Organization Name
          example: example_org
          in: path
          name: org_name
          required: true
          schema:
            type: string
        - description: Product Name
          example: example_product
          in: path
          name: product_name
          required: true
          schema:
            type: string
        - description: Device Identifier
          example: example_device
          in: path
          name: identifier
          required: true
          schema:
            type: string
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeviceSharedSecretCreateResponse'
          description: Device Shared Secret create response
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Forbidden
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Entity
      callbacks: {}
      security:
        - bearer_auth: []
components:
  schemas:
    DeviceSharedSecretCreateResponse:
      description: Device shared secret create response
      properties:
        data:
          $ref: '#/components/schemas/DeviceSharedSecretWithSecret'
      title: DeviceSharedSecretCreateResponse
      type: object
    ErrorResponse:
      description: Error response
      example:
        errors:
          detail: Resource Not Found or Authorization Insufficient
      properties:
        errors:
          properties:
            detail:
              type: string
          type: object
      title: ErrorResponse
      type: object
    DeviceSharedSecretWithSecret:
      allOf:
        - $ref: '#/components/schemas/DeviceSharedSecret'
        - properties:
            secret:
              description: The secret the device signs its connection with
              type: string
          type: object
      description: >-
        A newly created device shared secret. The secret is only returned once,
        in this response.
      example:
        deactivated_at: null
        inserted_at: '2026-10-08T12:00:00'
        key: nhd_[43 URL-safe characters]
        last_used: null
        secret: '[43 random characters]'
      title: DeviceSharedSecretWithSecret
    DeviceSharedSecret:
      description: A device's shared secret, without the secret itself
      example:
        deactivated_at: null
        inserted_at: '2026-10-08T12:00:00'
        key: nhd_[43 URL-safe characters]
        last_used: '2026-10-08T12:30:00Z'
      properties:
        deactivated_at:
          description: When the secret was deactivated, or null while it is active
          format: date-time
          nullable: true
          type: string
        inserted_at:
          description: >-
            When it was created, in UTC. Written without an offset, such as
            `2026-01-15T09:34:27`, so not an RFC 3339 `date-time`.
          type: string
        key:
          description: The key the device sends as `x-nh-key`
          type: string
        last_used:
          description: >-
            When the device last connected with the secret, or null if it never
            has
          format: date-time
          nullable: true
          type: string
      title: DeviceSharedSecret
      type: object
  securitySchemes:
    bearer_auth:
      description: >
        A user API token, or a product API key created in a product's settings.


        A product API key only works on the routes for its own product, under

        `/api/orgs/{org_name}/products/{product_name}`, and on
        `/api/devices/{identifier}`

        for that product's devices. What it may do there is decided by the role
        it

        holds, the same way a member's role decides what they may do.
      scheme: bearer
      type: http

````

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