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

# Create Smart Account

> Create a passkey and Grid smart account in one atomic operation.

<Warning>
  The "Try It" feature is disabled because this endpoint requires a WebAuthn authenticator response. Use the [Integration Guide](/grid/v1/accounts/passkeys/integration-guide) for implementation examples.
</Warning>

Creates both a passkey account and a Grid smart account in a **single atomic transaction**. Pass the raw WebAuthn `authenticatorResponse` directly—the passkey does not need to exist beforehand.

<Note>
  This endpoint creates the passkey from your WebAuthn response. You do **not** need to call `/passkeys/submit` first.
</Note>

## What Gets Created

In one transaction:

* **Passkey account** — derived from your WebAuthn public key
* **1/1 smart account** — with the passkey as sole signer (mask=7: full permissions)
* **Database records** — GridUser, GridSmartAccount, and audit trail
* **1 USDC funding** — sandbox only

## Implementation Flow (Direct API)

<Steps>
  <Step title="Generate Session Key">
    Create a Solana keypair for the session.
  </Step>

  <Step title="Get Current Slot">
    Fetch the current Solana slot number for replay protection.
  </Step>

  <Step title="Trigger WebAuthn">
    Call `navigator.credentials.create()` to create the passkey on the user's device.
  </Step>

  <Step title="Call This Endpoint">
    Pass the raw `authenticatorResponse` to create both accounts atomically.
  </Step>
</Steps>

```typescript theme={null}
// After WebAuthn ceremony completes
const response = await fetch("/passkeys/account", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_KEY",
    "x-grid-environment": "sandbox"
  },
  body: JSON.stringify({
    sessionKey: { key: sessionPublicKey, expiration: 900 },
    slotNumber: currentSlot,
    authenticatorResponse: credential.response  // raw WebAuthn response
  })
});
```

## Timing Constraints

The `slotNumber` must be within Solana's SlotHashes window (\~3 minutes / 512 slots). If you encounter slot-related errors, fetch a fresh slot and retry.

<Warning>
  **Environment Isolation**: Smart accounts have different addresses in sandbox vs production. Never send funds to the wrong environment.
</Warning>

## Related Endpoints

* [Create Passkey Session](/grid/v1/api-reference/endpoint/passkeys/post) — Hosted UI flow (alternative)
* [Integration Guide](/grid/v1/accounts/passkeys/integration-guide) — Complete implementation examples

<ResponseExample>
  ```json Response theme={null}
  {
    "address": "5nPmK...smartAccountAddress",
    "type": "passkey",
    "status": "active",
    "policies": {
      "threshold": 1,
      "admin_address": null
    },
    "authentication": [
      {
        "provider": "passkey",
        "session": {
          "Passkey": {
            "passkey_account": "7xK2...passkeyAddress",
            "pubkey": "base58EncodedPublicKey",
            "relying_party_id": "grid.squads.xyz",
            "session_key": {
              "key": "sessionPublicKey",
              "expiration": 1706832000
            }
          }
        }
      }
    ],
    "created_at": "2025-02-01T12:00:00Z",
    "updated_at": "2025-02-01T12:00:00Z"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /api/grid/v1/passkeys/account
openapi: 3.1.0
info:
  title: Grid v1 API
  description: Grid v1 REST API for Solana-based smart account system
  contact:
    name: Grid API Support
    url: https://squads.so
    email: support@squads.so
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://grid.squads.xyz
    description: Production server
security:
  - bearer_auth: []
tags:
  - name: accounts
    description: Smart account management operations
  - name: spending-limits
    description: Spending limit management
  - name: standing-orders
    description: Standing order operations
  - name: transactions
    description: Transaction management
  - name: trade
    description: Trade operations and management
  - name: payments
    description: Payment intent operations
  - name: passkeys
    description: Passkey management
  - name: kyc
    description: Know Your Customer operations
  - name: external-accounts
    description: External bank account management
  - name: virtual-accounts
    description: Virtual account management
  - name: auth
    description: Authentication operations
  - name: proposals
    description: Proposal management for multi-sig operations
  - name: compliance
    description: Compliance entity management and KYB/KYC operations
paths:
  /api/grid/v1/passkeys/account:
    post:
      tags:
        - passkeys
      summary: Create smart account with passkey
      description: >-
        Create a new smart account with a passkey as the initial signer. The
        passkey account must already exist (created via POST /passkeys and POST
        /passkeys/submit). This creates a 1/1 smart account with the passkey
        having full permissions.
      operationId: handler
      parameters:
        - name: x-grid-environment
          in: header
          description: Solana network environment (sandbox, devnet, mainnet)
          required: true
          schema:
            type: string
          example: sandbox
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePasskeyAccountRequestPayload'
        required: true
      responses:
        '201':
          description: Smart account created successfully with passkey signer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatePasskeyAccountResponsePayload'
        '400':
          description: Invalid request parameters
        '404':
          description: Passkey account not found
        '500':
          description: Internal server error
      security:
        - bearer_auth: []
components:
  schemas:
    CreatePasskeyAccountRequestPayload:
      type: object
      required:
        - sessionKey
        - slotNumber
        - authenticatorResponse
      properties:
        adminAddress:
          type:
            - string
            - 'null'
        authenticatorResponse:
          type: object
        memo:
          type:
            - string
            - 'null'
        sessionKey:
          $ref: '#/components/schemas/SessionKey'
        slotNumber:
          type: integer
          format: int64
          minimum: 0
    CreatePasskeyAccountResponsePayload:
      type: object
      required:
        - address
        - type
        - status
        - policies
        - authentication
        - created_at
        - updated_at
      properties:
        address:
          type: string
        authentication:
          type: array
          items:
            $ref: '#/components/schemas/AuthenticationProvider'
        created_at:
          type: string
          format: date-time
        policies:
          $ref: '#/components/schemas/AccountPolicies'
        status:
          type: string
        type:
          type: string
        updated_at:
          type: string
          format: date-time
    SessionKey:
      type: object
      description: >-
        Grid v1 API SessionKey type that supports backward-compatible
        deserialization

        from both raw bytes array (old format) and base58 string (new format).

        Always serializes to base58 string format.
      required:
        - key
        - expiration
      properties:
        expiration:
          type: integer
          format: int64
          minimum: 0
        key:
          type: string
          example: '11111111111111111111111111111111'
    AuthenticationProvider:
      type: object
      required:
        - provider
        - session
      properties:
        provider:
          $ref: '#/components/schemas/GridMPCProvider'
        session:
          $ref: '#/components/schemas/Session'
    AccountPolicies:
      type: object
      required:
        - signers
        - threshold
      properties:
        admin_address:
          type:
            - string
            - 'null'
        signers:
          type: array
          items:
            $ref: '#/components/schemas/AccountSigner'
        threshold:
          type: integer
          format: int32
          minimum: 0
        time_lock:
          type:
            - integer
            - 'null'
          format: int32
          minimum: 0
    GridMPCProvider:
      type: string
      enum:
        - privy
        - dynamic
        - passkey
        - turnkey
        - external
    Session:
      oneOf:
        - type: object
          required:
            - Privy
          properties:
            Privy:
              $ref: '#/components/schemas/PrivySession'
        - type: object
          required:
            - Turnkey
          properties:
            Turnkey:
              $ref: '#/components/schemas/TurnkeySession'
        - type: object
          required:
            - Passkey
          properties:
            Passkey:
              $ref: '#/components/schemas/PasskeySession'
    AccountSigner:
      type: object
      required:
        - address
        - role
        - permissions
      properties:
        address:
          type: string
        permissions:
          type: array
          items:
            $ref: '#/components/schemas/Permission'
        provider:
          $ref: '#/components/schemas/GridMPCProvider'
        role:
          $ref: '#/components/schemas/GridSignerRole'
    PrivySession:
      type: object
      required:
        - user_id
        - session
        - token
        - privy_access_token
        - refresh_token
      properties:
        privy_access_token:
          type: string
        refresh_token:
          type: string
        session:
          $ref: '#/components/schemas/AuthenticateResponse'
        token:
          type: string
        user_id:
          type: string
    TurnkeySession:
      type: object
      required:
        - user_id
        - api_key_id
        - credential_bundle
      properties:
        api_key_id:
          type: string
        credential_bundle:
          type: string
        user_id:
          type: string
    PasskeySession:
      type: object
      required:
        - passkey_account
        - pubkey
        - relying_party_id
        - session_key
      properties:
        passkey_account:
          type: string
        pubkey:
          type: string
        relying_party_id:
          type: string
        session_key:
          $ref: '#/components/schemas/SessionKey'
    Permission:
      type: string
      enum:
        - CAN_INITIATE
        - CAN_VOTE
        - CAN_EXECUTE
    GridSignerRole:
      type: string
      enum:
        - primary
        - backup
    AuthenticateResponse:
      type: object
      required:
        - expires_at
        - wallets
      properties:
        authorization_key:
          type:
            - string
            - 'null'
        encrypted_authorization_key:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/EncryptedAuthorizationKey'
        expires_at:
          type: integer
          format: int64
          minimum: 0
        wallets:
          type: array
          items:
            $ref: '#/components/schemas/Wallet'
    EncryptedAuthorizationKey:
      type: object
      required:
        - encryption_type
        - encapsulated_key
        - ciphertext
      properties:
        ciphertext:
          type: string
        encapsulated_key:
          type: string
        encryption_type:
          type: string
    Wallet:
      type: object
      required:
        - id
        - address
        - created_at
        - chain_type
        - policy_ids
        - additional_signers
      properties:
        additional_signers:
          type: array
          items:
            $ref: '#/components/schemas/AdditionalSigner'
        address:
          type: string
        chain_type:
          $ref: '#/components/schemas/WalletChainType'
        created_at:
          type: integer
          format: int64
          minimum: 0
        exported_at:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
        id:
          type: string
        imported_at:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
        owner_id:
          type:
            - string
            - 'null'
        policy_ids:
          type: array
          items:
            type: string
        public_key:
          type:
            - string
            - 'null'
    AdditionalSigner:
      type: object
      required:
        - signer_id
      properties:
        override_policy_ids:
          type: array
          items:
            type: string
          nullable: true
        signer_id:
          type: string
    WalletChainType:
      type: string
      enum:
        - solana
        - ethereum
        - cosmos
        - stellar
        - sui
        - tron
        - bitcoin-segwit
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: Your Grid API key from the Grid Dashboard

````