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

# Check preference

> Resolve a single `(target, medium)` for a recipient: whether a send would **actually** deliver.

`state.enabled` is the resolved decision, computed by the same cascade the delivery path uses — the recipient's exact rule → the recipient's `topic: any` rule → the project's exact rule → the project's `topic: any` rule → the medium's default (`in_app` delivers, every other medium does not). A `topic: none` target never takes an `any` rule.

The target does **not** need to be in your catalog; any `(channel, topic, event)` resolves. `state.cataloged` reports whether a project-level rule exists for this exact `(target, medium)` — context, not a gate.

💡 You could use this API to conditionally render something based on whether the recipient has subscribed to the target or not.

`state.enabled` is **resolved** — it is what a send to this `(target, medium)` would actually do, computed by the same [cascade](/docs/concepts/preferences#how-a-preference-resolves) the delivery path uses. The target does not need to be cataloged, or stored at all; any `(channel, topic, event)` resolves.

* `inherited: false` means the recipient **has** explicitly overridden this `(target, medium)`; `true` means the value came from elsewhere in the cascade.
* `cataloged: false` means your project has no rule declared for that exact `(target, medium)` — context for rendering, not a predictor of delivery.

<Note>
  Remember the default is **per medium**: with nothing set anywhere, `in_app` resolves to `enabled: true` and `email` resolves to `enabled: false`.
</Note>


## OpenAPI

````yaml GET /recipients/{recipient_id}/preferences/check
openapi: 3.0.3
info:
  title: Bodhveda Notifications API
  version: '1.0'
  description: API for sending notifications to recipients or broadcasting to all.
servers: []
security: []
paths:
  /recipients/{recipient_id}/preferences/check:
    get:
      tags:
        - Preferences
      summary: Check recipient's subscription state for a target
      description: >-
        Resolve a single `(target, medium)` for a recipient: whether a send
        would **actually** deliver.


        `state.enabled` is the resolved decision, computed by the same cascade
        the delivery path uses — the recipient's exact rule → the recipient's
        `topic: any` rule → the project's exact rule → the project's `topic:
        any` rule → the medium's default (`in_app` delivers, every other medium
        does not). A `topic: none` target never takes an `any` rule.


        The target does **not** need to be in your catalog; any `(channel,
        topic, event)` resolves. `state.cataloged` reports whether a
        project-level rule exists for this exact `(target, medium)` — context,
        not a gate.
      operationId: checkRecipientTargetSubscription
      parameters:
        - name: recipient_id
          in: path
          required: true
          schema:
            type: string
          description: The unique identifier of the recipient.
        - name: channel
          in: query
          required: true
          schema:
            type: string
          description: Channel to check.
        - name: topic
          in: query
          required: true
          schema:
            type: string
          description: Topic to check.
        - name: event
          in: query
          required: true
          schema:
            type: string
          description: Event to check.
        - name: medium
          in: query
          required: false
          schema:
            type: string
            enum:
              - in_app
              - email
            default: in_app
          description: >-
            Which medium to check the subscription state for. Defaults to
            `in_app`.
      responses:
        '200':
          description: Subscription state for the target
          content:
            application/json:
              examples:
                Target Subscription State:
                  summary: Target Subscription State Response
                  value:
                    data:
                      target:
                        channel: posts
                        topic: post_id_123
                        event: new_comment
                        medium: email
                      state:
                        enabled: true
                        inherited: false
                        cataloged: false
      security:
        - BearerAuthWithAPIKeyWithEitherScope: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: >-
            curl -G
            https://api.bodhveda.com/recipients/recipient_123/preferences/check
            \
              -H "Authorization: Bearer bv_xxxxxxxxx" \
              --data-urlencode "channel=posts" \
              --data-urlencode "topic=post_id_123" \
              --data-urlencode "event=new_comment" \
              --data-urlencode "medium=email" 
        - lang: javascript
          label: JavaScript
          source: >-
            import { Bodhveda } from "@bodhveda/js";


            const bodhveda = new Bodhveda("bv_xxxxxxxxx");


            const res = await
            bodhveda.recipients.preferences.check("recipient_123", {
                target: { channel: "posts", topic: "post_id_123", event: "new_comment" },
                medium: "email",
            });

            // res.state.enabled
        - lang: go
          label: Go
          source: >-
            import (
                "context"

                bodhveda "github.com/MudgalLabs/bodhveda/sdk/go"
            )


            ctx := context.Background()

            client := bodhveda.NewClient("bv_xxxxxxxxx", nil)


            res, _ := client.Recipients.Preferences.Check(ctx, "recipient_123",
            &bodhveda.CheckPreferenceRequest{
                Target: bodhveda.Target{Channel: "posts", Topic: "post_id_123", Event: "new_comment"},
                Medium: bodhveda.MediumEmail,
            })

            // res.State.Enabled
        - lang: jsx
          label: React
          source: >-
            import { useCheckPreference } from "@bodhveda/react";


            // Requires a <BodhvedaProvider recipientID="recipient_123"> higher
            in the tree.

            function Subscribed() {
                const { data } = useCheckPreference({
                    channel: "posts",
                    topic: "post_id_123",
                    event: "new_comment",
                });
                return <span>{data?.state.enabled ? "Subscribed" : "Muted"}</span>;
            }
components:
  securitySchemes:
    BearerAuthWithAPIKeyWithEitherScope:
      type: http
      scheme: bearer
      bearerFormat: APIKey
      description: >-
        Bearer authentication header of the form `Bearer bv_xxxxxxxxx`, where
        `bv_xxxxxxxxx` is your **API Key** with `Full access` or `Recipient
        acess` scope.

````