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

# Create an Access Grant

> Creates a new [Access Grant](https://docs.seam.co/use-cases/granting-access). Access Grants are the default and recommended way to grant a user access to any physical space, irrespective of the locking hardware. They work with both standalone smart locks (using `device_ids`) and access control systems (using `acs_entrance_ids` or `space_ids`), and can issue PIN codes, key cards, and mobile keys through a single request.



## OpenAPI

````yaml /openapi.json post /access_grants/create
openapi: 3.0.0
info:
  title: Seam Connect
  version: 1.0.0
servers:
  - url: https://connect.getseam.com
security: []
tags:
  - description: access_codes
    name: /access_codes
  - description: acs
    name: /acs
  - description: action_attempts
    name: /action_attempts
  - description: client_sessions
    name: /client_sessions
  - description: connected_accounts
    name: /connected_accounts
  - description: connect_webviews
    name: /connect_webviews
  - description: devices
    name: /devices
  - description: events
    name: /events
  - description: health
    name: /health
  - description: locks
    name: /locks
  - description: networks
    name: /networks
  - description: noise_sensors
    name: /noise_sensors
  - description: phones
    name: /phones
  - description: thermostats
    name: /thermostats
  - description: user_identities
    name: /user_identities
  - description: webhooks
    name: /webhooks
  - description: workspaces
    name: /workspaces
paths:
  /access_grants/create:
    post:
      tags: []
      summary: Create an Access Grant
      description: >-
        Creates a new [Access
        Grant](https://docs.seam.co/use-cases/granting-access). Access Grants
        are the default and recommended way to grant a user access to any
        physical space, irrespective of the locking hardware. They work with
        both standalone smart locks (using `device_ids`) and access control
        systems (using `acs_entrance_ids` or `space_ids`), and can issue PIN
        codes, key cards, and mobile keys through a single request.
      operationId: accessGrantsCreatePost
      requestBody:
        content:
          application/json:
            schema:
              allOf:
                - oneOf:
                    - properties:
                        user_identity_id:
                          description: >-
                            ID of user identity for whom access is being
                            granted.
                          format: uuid
                          type: string
                      required:
                        - user_identity_id
                      type: object
                    - properties:
                        user_identity:
                          description: >-
                            When used, creates a new user identity with the
                            given details, and grants them access.
                          properties:
                            email_address:
                              description: Unique email address for the user identity.
                              format: email
                              nullable: true
                              type: string
                            full_name:
                              minLength: 1
                              nullable: true
                              type: string
                            phone_number:
                              description: >-
                                Unique phone number for the user identity in
                                [E.164
                                format](https://www.itu.int/rec/T-REC-E.164/en)
                                (for example, +15555550100).
                              nullable: true
                              type: string
                            user_identity_key:
                              description: Unique key for the user identity.
                              minLength: 1
                              nullable: true
                              type: string
                          type: object
                      required:
                        - user_identity
                      type: object
                - properties:
                    access_grant_key:
                      description: Unique key for the access grant within the workspace.
                      minLength: 1
                      type: string
                    acs_entrance_ids:
                      default: []
                      description: >-
                        Set of IDs of the
                        [entrances](https://docs.seam.co/api/acs/systems/list)
                        to which access is being granted.
                      items:
                        format: uuid
                        type: string
                      type: array
                    customization_profile_id:
                      description: >-
                        ID of the customization profile to apply to the Access
                        Grant and its access methods.
                      format: uuid
                      type: string
                    device_ids:
                      default: []
                      description: >-
                        Set of IDs of the
                        [devices](https://docs.seam.co/api/devices/list) to
                        which access is being granted.
                      items:
                        format: uuid
                        type: string
                      type: array
                    ends_at:
                      default: null
                      description: >-
                        Date and time at which the validity of the new grant
                        ends, in [ISO
                        8601](https://www.iso.org/iso-8601-date-and-time-format.html)
                        format. Must be a time in the future and after
                        `starts_at`.
                      nullable: true
                      type: string
                    location:
                      deprecated: true
                      properties:
                        acs_entrance_ids:
                          default: []
                          deprecated: true
                          items:
                            format: uuid
                            type: string
                          type: array
                          x-deprecated: Use `acs_entrance_ids` at the top level.
                        device_ids:
                          default: []
                          deprecated: true
                          items:
                            format: uuid
                            type: string
                          type: array
                          x-deprecated: Use `device_ids` at the top level.
                        name:
                          description: Name of the location.
                          type: string
                      type: object
                      x-deprecated: >-
                        Create a space first, then reference it using
                        `space_ids`.
                    location_ids:
                      deprecated: true
                      items:
                        format: uuid
                        type: string
                      type: array
                      x-deprecated: Use `space_ids`.
                    name:
                      description: Name for the access grant.
                      nullable: true
                      type: string
                    requested_access_methods:
                      items:
                        properties:
                          code:
                            description: >-
                              Specific PIN code to use for this access method.
                              Only applicable when mode is 'code'.
                            maxLength: 9
                            minLength: 4
                            pattern: ^\d+$
                            type: string
                          instant_key_max_use_count:
                            description: >-
                              Maximum number of times the instant key can be
                              used. Only applicable when mode is 'mobile_key'.
                              Defaults to 1 if not specified.
                            minimum: 1
                            type: integer
                          mode:
                            description: >-
                              Access method mode. Supported values: `code`,
                              `card`, `mobile_key`, `cloud_key`.
                            enum:
                              - code
                              - card
                              - mobile_key
                              - cloud_key
                            type: string
                        required:
                          - mode
                        type: object
                      type: array
                    reservation_key:
                      description: Reservation key for the access grant.
                      type: string
                    space_ids:
                      description: >-
                        Set of IDs of existing spaces to which access is being
                        granted.
                      items:
                        format: uuid
                        type: string
                      type: array
                    space_keys:
                      description: >-
                        Set of keys of existing spaces to which access is being
                        granted.
                      items:
                        minLength: 1
                        type: string
                      type: array
                    starts_at:
                      description: >-
                        Date and time at which the validity of the new grant
                        starts, in [ISO
                        8601](https://www.iso.org/iso-8601-date-and-time-format.html)
                        format.
                      type: string
                  required:
                    - requested_access_methods
                  type: object
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  access_grant:
                    $ref: '#/components/schemas/access_grant'
                  ok:
                    type: boolean
                required:
                  - access_grant
                  - ok
                type: object
          description: OK
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
      security:
        - pat_with_workspace: []
        - console_session_with_workspace: []
        - api_key: []
        - client_session_with_customer: []
      x-codeSamples:
        - lang: javascript
          label: Seam SDK
          source: |-
            await seam.accessGrants.create({
              user_identity_id: "e3d736c1-540d-4d10-83e5-9a4e135453b4",
              device_ids: ["6ba7b811-9dad-11d1-80b4-00c04fd430c8"],
              requested_access_methods: [{ mode: "code" }],
              starts_at: "2025-06-16T16:54:17.946606Z",
              ends_at: "2025-06-18T16:54:17.946606Z",
            });

            /*
            {
              "access_grant_id": "ef83cca9-5fdf-4ac2-93f3-c21c5a8be54b",
              "access_method_ids": [
                "a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d"
              ],
              "created_at": "2025-06-16T16:54:17.946606Z",
              "display_name": "My Access Grant",
              "ends_at": "2025-06-18T16:54:17.946606Z",
              "requested_access_methods": [
                {
                  "display_name": "PIN Code Credential",
                  "mode": "code",
                  "created_at": "2025-06-16T16:54:17.946606Z",
                  "created_access_method_ids": [
                    "a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d"
                  ]
                }
              ],
              "starts_at": "2025-06-16T16:54:17.946606Z",
              "user_identity_id": "e3d736c1-540d-4d10-83e5-9a4e135453b4",
              "workspace_id": "750fc0bc-4450-4356-8d9f-18c6a3a6b2c7"
            }
            */
        - lang: bash
          label: cURL
          source: >-
            curl --include --request POST
            "https://connect.getseam.com/access_grants/create" \
              --header "Authorization: Bearer $SEAM_API_KEY" \
              --json @- <<EOF
            {
              "user_identity_id": "e3d736c1-540d-4d10-83e5-9a4e135453b4",
              "device_ids": [
                "6ba7b811-9dad-11d1-80b4-00c04fd430c8"
              ],
              "requested_access_methods": [
                {
                  "mode": "code"
                }
              ],
              "starts_at": "2025-06-16T16:54:17.946606Z",
              "ends_at": "2025-06-18T16:54:17.946606Z"
            }

            EOF


            # Response:

            # {

            #   "access_grant": {

            #     "access_grant_id": "ef83cca9-5fdf-4ac2-93f3-c21c5a8be54b",

            #     "access_method_ids": [

            #       "a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d"

            #     ],

            #     "created_at": "2025-06-16T16:54:17.946606Z",

            #     "display_name": "My Access Grant",

            #     "ends_at": "2025-06-18T16:54:17.946606Z",

            #     "requested_access_methods": [

            #       {

            #         "display_name": "PIN Code Credential",

            #         "mode": "code",

            #         "created_at": "2025-06-16T16:54:17.946606Z",

            #         "created_access_method_ids": [

            #           "a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d"

            #         ]

            #       }

            #     ],

            #     "starts_at": "2025-06-16T16:54:17.946606Z",

            #     "user_identity_id": "e3d736c1-540d-4d10-83e5-9a4e135453b4",

            #     "workspace_id": "750fc0bc-4450-4356-8d9f-18c6a3a6b2c7"

            #   }

            # }
        - lang: python
          label: Seam SDK
          source: |-
            seam.access_grants.create(
                user_identity_id="e3d736c1-540d-4d10-83e5-9a4e135453b4",
                device_ids=["6ba7b811-9dad-11d1-80b4-00c04fd430c8"],
                requested_access_methods=[{"mode": "code"}],
                starts_at="2025-06-16T16:54:17.946606Z",
                ends_at="2025-06-18T16:54:17.946606Z",
            )

            # AccessGrant(
                access_grant_id="ef83cca9-5fdf-4ac2-93f3-c21c5a8be54b",
                access_method_ids=["a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d"],
                created_at="2025-06-16T16:54:17.946606Z",
                display_name="My Access Grant",
                ends_at="2025-06-18T16:54:17.946606Z",
                requested_access_methods=[
                    {
                        "display_name": "PIN Code Credential",
                        "mode": "code",
                        "created_at": "2025-06-16T16:54:17.946606Z",
                        "created_access_method_ids": ["a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d"],
                    }
                ],
                starts_at="2025-06-16T16:54:17.946606Z",
                user_identity_id="e3d736c1-540d-4d10-83e5-9a4e135453b4",
                workspace_id="750fc0bc-4450-4356-8d9f-18c6a3a6b2c7",
            )
        - lang: ruby
          label: Seam SDK
          source: |-
            seam.access_grants.create(
              user_identity_id: "e3d736c1-540d-4d10-83e5-9a4e135453b4",
              device_ids: ["6ba7b811-9dad-11d1-80b4-00c04fd430c8"],
              requested_access_methods: [{ mode: "code" }],
              starts_at: "2025-06-16T16:54:17.946606Z",
              ends_at: "2025-06-18T16:54:17.946606Z",
            )

            # => {
              "access_grant_id" => "ef83cca9-5fdf-4ac2-93f3-c21c5a8be54b",
              "access_method_ids" => ["a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d"],
              "created_at" => "2025-06-16T16:54:17.946606Z",
              "display_name" => "My Access Grant",
              "ends_at" => "2025-06-18T16:54:17.946606Z",
              "requested_access_methods" => [
                {
                  display_name: "PIN Code Credential",
                  mode: "code",
                  created_at: "2025-06-16T16:54:17.946606Z",
                  created_access_method_ids: ["a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d"],
                },
              ],
              "starts_at" => "2025-06-16T16:54:17.946606Z",
              "user_identity_id" => "e3d736c1-540d-4d10-83e5-9a4e135453b4",
              "workspace_id" => "750fc0bc-4450-4356-8d9f-18c6a3a6b2c7",
            }
        - lang: php
          label: Seam SDK
          source: |-
            $seam->access_grants->create(
                user_identity_id: "e3d736c1-540d-4d10-83e5-9a4e135453b4",
                device_ids: ["6ba7b811-9dad-11d1-80b4-00c04fd430c8"],
                requested_access_methods: [["mode" => "code"]],
                starts_at: "2025-06-16T16:54:17.946606Z",
                ends_at: "2025-06-18T16:54:17.946606Z",
            );

            // [
                "access_grant_id" => "ef83cca9-5fdf-4ac2-93f3-c21c5a8be54b",
                "access_method_ids" => ["a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d"],
                "created_at" => "2025-06-16T16:54:17.946606Z",
                "display_name" => "My Access Grant",
                "ends_at" => "2025-06-18T16:54:17.946606Z",
                "requested_access_methods" => [
                    [
                        "display_name" => "PIN Code Credential",
                        "mode" => "code",
                        "created_at" => "2025-06-16T16:54:17.946606Z",
                        "created_access_method_ids" => [
                            "a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d",
                        ],
                    ],
                ],
                "starts_at" => "2025-06-16T16:54:17.946606Z",
                "user_identity_id" => "e3d736c1-540d-4d10-83e5-9a4e135453b4",
                "workspace_id" => "750fc0bc-4450-4356-8d9f-18c6a3a6b2c7",
            ];
        - lang: bash
          label: Seam CLI
          source: >-
            seam access-grants create --user_identity_id
            "e3d736c1-540d-4d10-83e5-9a4e135453b4" --device_ids
            ["6ba7b811-9dad-11d1-80b4-00c04fd430c8"] --requested_access_methods
            [{"mode":"code"}] --starts_at "2025-06-16T16:54:17.946606Z"
            --ends_at "2025-06-18T16:54:17.946606Z"


            # {

            #   "access_grant_id": "ef83cca9-5fdf-4ac2-93f3-c21c5a8be54b",

            #   "access_method_ids": [

            #     "a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d"

            #   ],

            #   "created_at": "2025-06-16T16:54:17.946606Z",

            #   "display_name": "My Access Grant",

            #   "ends_at": "2025-06-18T16:54:17.946606Z",

            #   "requested_access_methods": [

            #     {

            #       "display_name": "PIN Code Credential",

            #       "mode": "code",

            #       "created_at": "2025-06-16T16:54:17.946606Z",

            #       "created_access_method_ids": [

            #         "a1b2c3d4-e5f6-4a3b-2c1d-0e9f8a7b6c5d"

            #       ]

            #     }

            #   ],

            #   "starts_at": "2025-06-16T16:54:17.946606Z",

            #   "user_identity_id": "e3d736c1-540d-4d10-83e5-9a4e135453b4",

            #   "workspace_id": "750fc0bc-4450-4356-8d9f-18c6a3a6b2c7"

            # }
components:
  schemas:
    access_grant:
      description: >-
        Represents an Access Grant. Access Grants enable you to grant a user
        identity access to spaces, entrances, and devices through one or more
        access methods, such as mobile keys, plastic cards, and PIN codes. You
        can create an Access Grant for an existing user identity, or you can
        create a new user identity *while* creating the new Access Grant.
      properties:
        access_grant_id:
          description: ID of the Access Grant.
          format: uuid
          type: string
        access_grant_key:
          description: Unique key for the access grant within the workspace.
          type: string
        access_method_ids:
          description: IDs of the access methods created for the Access Grant.
          items:
            format: uuid
            type: string
          type: array
        client_session_token:
          description: >-
            Client Session Token. Only returned if the Access Grant has a
            mobile_key access method.
          type: string
        created_at:
          description: Date and time at which the Access Grant was created.
          format: date-time
          type: string
        customization_profile_id:
          description: ID of the customization profile associated with the Access Grant.
          format: uuid
          type: string
        display_name:
          description: Display name of the Access Grant.
          type: string
        ends_at:
          description: Date and time at which the Access Grant ends.
          format: date-time
          nullable: true
          type: string
        errors:
          description: >-
            Errors associated with the [access
            grant](https://docs.seam.co/use-cases/granting-access).
          items:
            discriminator:
              propertyName: error_code
            oneOf:
              - properties:
                  created_at:
                    description: Date and time at which Seam created the error.
                    format: date-time
                    type: string
                  error_code:
                    description: >-
                      Unique identifier of the type of error. Enables quick
                      recognition and categorization of the issue.
                    enum:
                      - cannot_create_requested_access_methods
                    type: string
                  message:
                    description: >-
                      Detailed description of the error. Provides insights into
                      the issue and potentially how to rectify it.
                    type: string
                  missing_device_ids:
                    description: >-
                      IDs of the devices that did not receive an access code at
                      grant creation. Use these to identify which specific
                      devices failed when the message reports a partial failure.
                    items:
                      format: uuid
                      type: string
                    type: array
                required:
                  - created_at
                  - message
                  - error_code
                type: object
          type: array
        instant_key_url:
          description: >-
            Instant Key URL. Only returned if the Access Grant has a single
            mobile_key access_method. 
          format: uri
          type: string
        location_ids:
          deprecated: true
          items:
            format: uuid
            type: string
          type: array
          x-deprecated: Use `space_ids`.
        name:
          description: >-
            Name of the Access Grant. If not provided, the display name will be
            computed.
          nullable: true
          type: string
        pending_mutations:
          description: >-
            List of pending mutations for the access grant. This shows updates
            that are in progress.
          items:
            discriminator:
              propertyName: mutation_code
            oneOf:
              - description: >-
                  Seam is in the process of updating the devices/spaces
                  associated with this access grant.
                properties:
                  created_at:
                    description: Date and time at which the mutation was created.
                    format: date-time
                    type: string
                  from:
                    description: Previous location configuration.
                    properties:
                      device_ids:
                        description: Previous device IDs where access codes existed.
                        items:
                          format: uuid
                          type: string
                        type: array
                    required:
                      - device_ids
                    type: object
                  message:
                    description: Detailed description of the mutation.
                    type: string
                  mutation_code:
                    description: >-
                      Mutation code to indicate that Seam is in the process of
                      updating the spaces (devices) associated with this access
                      grant.
                    enum:
                      - updating_spaces
                    type: string
                  to:
                    description: New location configuration.
                    properties:
                      common_code_key:
                        description: >-
                          Common code key to ensure PIN code reuse across
                          devices.
                        nullable: true
                        type: string
                      device_ids:
                        description: New device IDs where access codes should be created.
                        items:
                          format: uuid
                          type: string
                        type: array
                    required:
                      - device_ids
                    type: object
                required:
                  - created_at
                  - message
                  - mutation_code
                  - from
                  - to
                type: object
              - description: >-
                  Seam is in the process of updating the access times for this
                  access grant.
                properties:
                  access_method_ids:
                    description: IDs of the access methods being updated.
                    items:
                      format: uuid
                      type: string
                    type: array
                  created_at:
                    description: Date and time at which the mutation was created.
                    format: date-time
                    type: string
                  from:
                    description: Previous access time configuration.
                    properties:
                      ends_at:
                        description: Previous end time for access.
                        format: date-time
                        nullable: true
                        type: string
                      starts_at:
                        description: Previous start time for access.
                        format: date-time
                        nullable: true
                        type: string
                    required:
                      - starts_at
                      - ends_at
                    type: object
                  message:
                    description: Detailed description of the mutation.
                    type: string
                  mutation_code:
                    description: >-
                      Mutation code to indicate that Seam is in the process of
                      updating the access times for this access grant.
                    enum:
                      - updating_access_times
                    type: string
                  to:
                    description: New access time configuration.
                    properties:
                      ends_at:
                        description: New end time for access.
                        format: date-time
                        nullable: true
                        type: string
                      starts_at:
                        description: New start time for access.
                        format: date-time
                        nullable: true
                        type: string
                    required:
                      - starts_at
                      - ends_at
                    type: object
                required:
                  - created_at
                  - message
                  - mutation_code
                  - access_method_ids
                  - from
                  - to
                type: object
          type: array
        requested_access_methods:
          description: Access methods that the user requested for the Access Grant.
          items:
            properties:
              code:
                description: >-
                  Specific PIN code to use for this access method. Only
                  applicable when mode is 'code'.
                maxLength: 9
                minLength: 4
                pattern: ^\d+$
                type: string
              created_access_method_ids:
                description: >-
                  IDs of the access methods created for the requested access
                  method.
                items:
                  format: uuid
                  type: string
                type: array
              created_at:
                description: >-
                  Date and time at which the requested access method was added
                  to the Access Grant.
                format: date-time
                type: string
              display_name:
                description: Display name of the access method.
                type: string
              instant_key_max_use_count:
                description: >-
                  Maximum number of times the instant key can be used. Only
                  applicable when mode is 'mobile_key'. Defaults to 1 if not
                  specified.
                minimum: 1
                type: integer
              mode:
                description: >-
                  Access method mode. Supported values: `code`, `card`,
                  `mobile_key`, `cloud_key`.
                enum:
                  - code
                  - card
                  - mobile_key
                  - cloud_key
                type: string
            required:
              - display_name
              - mode
              - created_at
              - created_access_method_ids
            type: object
          type: array
        reservation_key:
          description: Reservation key for the access grant.
          type: string
        space_ids:
          description: IDs of the spaces to which the Access Grant gives access.
          items:
            format: uuid
            type: string
          type: array
        starts_at:
          description: Date and time at which the Access Grant starts.
          format: date-time
          type: string
        user_identity_id:
          description: ID of user identity to which the Access Grant gives access.
          format: uuid
          type: string
        warnings:
          type: array
          description: >-
            Warnings associated with the [access
            grant](https://docs.seam.co/use-cases/granting-access).
          items:
            type: object
            properties:
              error_code:
                type: string
                description: Error or warning code.
              message:
                type: string
                description: Human-readable description.
              created_at:
                type: string
                format: date-time
                description: When this error or warning was generated.
        workspace_id:
          description: ID of the Seam workspace associated with the Access Grant.
          format: uuid
          type: string
      required:
        - workspace_id
        - access_grant_id
        - user_identity_id
        - location_ids
        - space_ids
        - requested_access_methods
        - access_method_ids
        - name
        - display_name
        - created_at
        - starts_at
        - ends_at
        - warnings
        - errors
        - pending_mutations
      type: object
      x-draft: Early access.
      x-route-path: /access_grants
  securitySchemes:
    pat_with_workspace:
      bearerFormat: API Token
      scheme: bearer
      type: http
    console_session_with_workspace:
      bearerFormat: Console Session Token
      scheme: bearer
      type: http
    api_key:
      bearerFormat: API Key
      scheme: bearer
      type: http
    client_session_with_customer:
      bearerFormat: Customer Client Session Token
      scheme: bearer
      type: http

````