> ## Documentation Index
> Fetch the complete documentation index at: https://conductorone-leet-slack-mcp-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Count Grants For User By App

> CountGrantsForUserByApp returns, for a user, the number of grants held per
 application. Use it to size or filter an access graph before calling
 SearchGraph: counts are computed directly from grant bindings and are an
 upper bound on what SearchGraph will render for the same user and app
 filter (SearchGraph applies additional filters that this count does not).



## OpenAPI

````yaml https://spec.speakeasy.com/conductor-one/conductorone/my-source-with-code-samples post /api/v1/search/graph/counts
openapi: 3.1.0
info:
  description: The C1 API is a HTTP API for managing C1 resources.
  title: C1 API
  version: 0.1.0-alpha
servers:
  - description: The C1 API server for the current tenant.
    url: https://{tenantDomain}.conductor.one
    variables:
      tenantDomain:
        default: example
        description: The domain of the tenant to use for this request.
security:
  - bearerAuth: []
    oauth: []
paths:
  /api/v1/search/graph/counts:
    post:
      tags:
        - App Entitlement
      summary: Count Grants For User By App
      description: >-
        CountGrantsForUserByApp returns, for a user, the number of grants held
        per
         application. Use it to size or filter an access graph before calling
         SearchGraph: counts are computed directly from grant bindings and are an
         upper bound on what SearchGraph will render for the same user and app
         filter (SearchGraph applies additional filters that this count does not).
      operationId: c1.api.app.v1.AppEntitlementSearchService.CountGrantsForUserByApp
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/c1.api.app.v1.AppEntitlementSearchServiceCountGrantsForUserByAppRequest
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/c1.api.app.v1.AppEntitlementSearchServiceCountGrantsForUserByAppResponse
          description: >-
            CountGrantsForUserByApp response. Grant counts are computed directly
            from
             grant bindings and are an upper bound on what SearchGraph renders for the
             same user and app filter — SearchGraph applies additional filters that
             these counts do not.
      x-codeSamples:
        - lang: go
          label: CountGrantsForUserByApp
          source: "package main\n\nimport(\n\t\"context\"\n\t\"github.com/conductorone/conductorone-sdk-go/pkg/models/shared\"\n\tconductoronesdkgo \"github.com/conductorone/conductorone-sdk-go\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := conductoronesdkgo.New(\n        conductoronesdkgo.WithSecurity(shared.Security{\n            BearerAuth: \"<YOUR_BEARER_TOKEN_HERE>\",\n            Oauth: \"<YOUR_OAUTH_HERE>\",\n        }),\n    )\n\n    res, err := s.AppEntitlementSearch.CountGrantsForUserByApp(ctx, nil)\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.AppEntitlementSearchServiceCountGrantsForUserByAppResponse != nil {\n        // handle response\n    }\n}"
components:
  schemas:
    c1.api.app.v1.AppEntitlementSearchServiceCountGrantsForUserByAppRequest:
      description: CountGrantsForUserByApp request.
      properties:
        appIds:
          description: >-
            Restrict the count to these applications. Empty counts grants across
            all
             applications the user has access to.
          items:
            type: string
          type:
            - array
            - 'null'
        userId:
          description: The user whose grants to count.
          type: string
      title: App Entitlement Search Service Count Grants For User By App Request
      type: object
      x-speakeasy-name-override: AppEntitlementSearchServiceCountGrantsForUserByAppRequest
    c1.api.app.v1.AppEntitlementSearchServiceCountGrantsForUserByAppResponse:
      description: >-
        CountGrantsForUserByApp response. Grant counts are computed directly
        from
         grant bindings and are an upper bound on what SearchGraph renders for the
         same user and app filter — SearchGraph applies additional filters that
         these counts do not.
      properties:
        appCount:
          description: The number of applications represented in app_grant_counts.
          format: int32
          type: integer
        appGrantCounts:
          description: >-
            Grant counts, one entry per application the user has at least one
            grant
             in (or per requested app_id, if narrower).
          items:
            $ref: '#/components/schemas/c1.api.app.v1.GraphAppGrantCount'
          type:
            - array
            - 'null'
        appUsers:
          description: >-
            The user's accounts, scoped by the app_ids filter when provided.
            Includes
             accounts with zero counted grants. Lets callers filter a subsequent access
             graph by account without a second lookup.
          items:
            $ref: '#/components/schemas/c1.api.app.v1.AppUserRef'
          type:
            - array
            - 'null'
        band:
          description: |-
            Advisory size classification for the user's access graph. See
             GraphSizeBand.
          enum:
            - GRAPH_SIZE_BAND_UNSPECIFIED
            - GRAPH_SIZE_BAND_NORMAL
            - GRAPH_SIZE_BAND_SUMMARIZED
            - GRAPH_SIZE_BAND_TOO_LARGE
          type: string
          x-speakeasy-unknown-values: allow
        totalGrants:
          description: The sum of grant_count across all app_grant_counts.
          format: int64
          type: string
      title: App Entitlement Search Service Count Grants For User By App Response
      type: object
      x-speakeasy-name-override: AppEntitlementSearchServiceCountGrantsForUserByAppResponse
    c1.api.app.v1.GraphAppGrantCount:
      description: The number of grants a user holds in a single application.
      properties:
        appId:
          description: The ID of the application.
          type: string
        grantCount:
          description: The number of grants the user holds in this application.
          format: int64
          type: string
      title: Graph App Grant Count
      type: object
      x-speakeasy-name-override: GraphAppGrantCount
    c1.api.app.v1.AppUserRef:
      description: The AppUserRef message.
      properties:
        appId:
          description: The ID of the application.
          type: string
        id:
          description: The ID of the app user.
          type: string
      title: App User Ref
      type: object
      x-speakeasy-name-override: AppUserRef
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http
    oauth:
      description: >-
        This API uses OAuth2 with the Client Credential flow.

        Client Credentials must be sent in the BODY, not the headers.

        For an example of how to implement this, refer to the
        [c1TokenSource.Token()](https://github.com/ConductorOne/conductorone-sdk-go/blob/3375fe7c0126d17e7ec4e711693dee7b791023aa/token_source.go#L101-L187)
        function.
      flows:
        clientCredentials:
          scopes: {}
          tokenUrl: /auth/v1/token
      type: oauth2

````