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

# List users

> List all users provisioned under an account with cursor-based pagination.



## OpenAPI

````yaml GET /accounts/{account_id}/users
openapi: 3.1.1
info:
  title: Surge
  version: '1.0'
servers:
  - url: https://api.surge.app
security:
  - authorization: []
paths:
  /accounts/{account_id}/users:
    get:
      tags:
        - Users
      summary: List users
      description: List all users for an account with cursor-based pagination.
      operationId: ListUsers
      parameters:
        - in: path
          name: account_id
          required: true
          schema:
            description: The account ID to list users for.
            example: acct_01j9a43avnfqzbjfch6pygv1td
            type: string
        - in: query
          name: after
          required: false
          schema:
            description: >-
              Cursor for forward pagination. Use the next_cursor from a previous
              response.
            type: string
        - in: query
          name: before
          required: false
          schema:
            description: >-
              Cursor for backward pagination. Use the previous_cursor from a
              previous response.
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserList'
          description: List of users
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Surge from '@surgeapi/node';


            const client = new Surge({
              apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
            });


            // Automatically fetches more pages as needed.

            for await (const user of
            client.users.list('acct_01j9a43avnfqzbjfch6pygv1td')) {
              console.log(user.id);
            }
        - lang: Python
          source: |-
            import os
            from surge import Surge

            client = Surge(
                api_key=os.environ.get("SURGE_API_KEY"),  # This is the default and can be omitted
            )
            page = client.users.list(
                account_id="acct_01j9a43avnfqzbjfch6pygv1td",
            )
            page = page.data[0]
            print(page.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/stainless-sdks/surge-go\"\n\t\"github.com/stainless-sdks/surge-go/option\"\n)\n\nfunc main() {\n\tclient := surge.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Users.List(\n\t\tcontext.TODO(),\n\t\t\"acct_01j9a43avnfqzbjfch6pygv1td\",\n\t\tsurge.UserListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n"
        - lang: Ruby
          source: |-
            require "surge_api"

            surge = SurgeAPI::Client.new(api_key: "My API Key")

            page = surge.users.list("acct_01j9a43avnfqzbjfch6pygv1td")

            puts(page)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Surge\Client;

            use Surge\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('SURGE_API_KEY') ?: 'My API
            Key');


            try {
              $page = $client->users->list(
                'acct_01j9a43avnfqzbjfch6pygv1td', after: 'after', before: 'before'
              );

              var_dump($page);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
components:
  schemas:
    UserList:
      description: A paginated list of users
      properties:
        data:
          description: The list of users
          items:
            $ref: '#/components/schemas/User'
          type: array
        pagination:
          $ref: '#/components/schemas/Pagination'
      required:
        - data
        - pagination
      title: UserList
      type: object
    ErrorResponse:
      description: An error response
      example:
        error:
          message: The requested resource could not be found.
          type: not_found
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
      title: ErrorResponse
      type: object
    User:
      description: A user of the app
      example:
        first_name: Brian
        id: usr_01j9dwavghe1ttppewekjjkfrx
        last_name: O'Conner
        metadata:
          email: boconner@toretti.family
          user_id: '1234'
        photo_url: https://toretti.family/people/brian.jpg
      properties:
        first_name:
          description: The user's first name.
          type: string
        id:
          description: Unique identifier for the object.
          type: string
        last_name:
          description: The user's last name.
          type: string
        metadata:
          $ref: '#/components/schemas/Metadata'
        photo_url:
          description: URL of a photo to be used as the user's avatar.
          format: uri
          type: string
      required:
        - first_name
      title: User
      type: object
    Pagination:
      description: Cursor-based pagination information
      example:
        next_cursor: g3QAAAABZAACaWRtAAAAGnBuXzAxamtzY2s5eDdkeW0wZnBxZjdjYmRyeQ==
        previous_cursor: null
      properties:
        next_cursor:
          description: Cursor for the next page of results. Null if there is no next page.
          type:
            - string
            - 'null'
        previous_cursor:
          description: >-
            Cursor for the previous page of results. Null if there is no
            previous page.
          type:
            - string
            - 'null'
      title: Pagination
      type: object
    Error:
      description: An error response
      example:
        message: The requested resource was not found.
        type: not_found
      properties:
        detail:
          additionalProperties: true
          description: Additional details about the error.
          type: object
        message:
          description: A human-readable error message.
          example: The requested resource was not found.
          type: string
        type:
          description: A unique error code.
          example: not_found
          type: string
      required:
        - type
        - message
      title: Error
      type: object
    Metadata:
      additionalProperties:
        maxLength: 500
        type: string
      description: Set of key-value pairs that will be stored with the object.
      maxProperties: 50
      properties: {}
      title: Metadata
      type: object
  securitySchemes:
    authorization:
      bearerFormat: Surge API token
      scheme: bearer
      type: http

````