--- title: Fulfillment Service description: >- Contains functions for verifying fulfillment service requests. See the [fulfillment service documentation](https://shopify.dev/docs/apps/fulfillment/fulfillment-service-apps) for more information. api_version: v3 api_name: shopify-app-remix source_url: html: >- https://shopify.dev/docs/api/shopify-app-remix/v3/authenticate/fulfillment-service md: >- https://shopify.dev/docs/api/shopify-app-remix/v3/authenticate/fulfillment-service.md --- # Fulfillment Service Contains functions for verifying fulfillment service requests. See the [fulfillment service documentation](https://shopify.dev/docs/apps/fulfillment/fulfillment-service-apps) for more information. ## authenticate.​fulfillment​Service([request](#authenticatefulfillmentservice-propertydetail-request)​) Verifies requests coming from Shopify to fulfillment service apps ### Parameters * request Request required ### Returns * Promise\> ### FulfillmentServiceContext * admin An admin context for the fulfillment service request. Returned only if there is a session for the shop. ```ts AdminApiContext ``` * payload The payload from the fulfillment service request. ```ts FulfillmentServicePayload ``` * session A session with an offline token for the shop. Returned only if there is a session for the shop. ```ts Session ``` ````ts export interface FulfillmentServiceContext< ConfigArg extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources, > { /** * A session with an offline token for the shop. * * Returned only if there is a session for the shop. * @example * Shopify session for the fulfillment service notification request. * Use the session associated with this request. * ```ts * // /app/routes/fulfillment_service_notification.tsx * import { ActionFunctionArgs } from "@remix-run/node"; * import { authenticate } from "../shopify.server"; * * export const action = async ({ request }: ActionFunctionArgs) => { * const { session, admin } = await authenticate.fulfillmentService(request); * * console.log(session.id) * * return new Response(); * }; * ``` * */ session: Session; /** * * An admin context for the fulfillment service request. * * Returned only if there is a session for the shop. * @example * Shopify session for the fulfillment service request. * Use the session associated with this request to use the Admin GraphQL API * ```ts * // /app/routes/fulfillment_order_notification.ts * import { ActionFunctionArgs } from "@remix-run/node"; * import { authenticate } from "../shopify.server"; * * export async function action({ request }: ActionFunctionArgs) { * const { admin, session } = await authenticate.fulfillmentService(request); * * console.log(session.id) * * return new Response(); * } * ``` */ admin: AdminApiContext; /** * The payload from the fulfillment service request. * * @example * Fulfillment service request payload. * Get the request's POST payload. * ```ts * /app/routes/fulfillment_order_notification.ts * import { ActionFunction } from "@remix-run/node"; * import { authenticate } from "../shopify.server"; * * export const action: ActionFunction = async ({ request }) => { * const { payload } = await authenticate.fulfillmentService(request); * if(payload.kind === 'FULFILLMENT_REQUEST') { * // handle fulfillment request * } else if (payload.kind === 'CANCELLATION_REQUEST') { * // handle cancellation request * }; * return new Response(); * ``` */ payload: FulfillmentServicePayload; } ```` ### FulfillmentServicePayload ```ts Record & { kind: string; } ``` Examples ### Examples * #### Consume a fulfillment service notification request ##### Description Handle a fulfillment service notification call ##### /app/routes/\*\*.ts ```typescript import {type ActionFunctionArgs} from '@remix-run/node'; import {authenticate} from '../shopify.server'; export const action = async ({request}: ActionFunctionArgs) => { const {admin, payload} = await authenticate.fulfillmentService(request); const kind = payload.kind; if (kind === 'FULFILLMENT_REQUEST') { const response = await admin?.graphql( `#graphql query { shop { assignedFulfillmentOrders(first: 10, assignmentStatus: FULFILLMENT_REQUESTED) { edges { node { id destination { firstName lastName } lineItems(first: 10) { edges { node { id productTitle sku remainingQuantity } } } merchantRequests(first: 10, kind: FULFILLMENT_REQUEST) { edges { node { message } } } } } } } }`, ); const fulfillments = await response.json(); console.log(fulfillments); } return new Response(); }; ``` * #### Shopify session for the fulfillment service request ##### Description Use the session associated with this request to use the Admin GraphQL API ##### /app/routes/fulfillment\_order\_notification.ts ```typescript import { ActionFunctionArgs } from "@remix-run/node"; import { authenticate } from "../shopify.server"; export async function action({ request }: ActionFunctionArgs) { const { admin, session } = await authenticate.fulfillmentService(request); console.log(session.id) return new Response(); } ``` * #### Fulfillment service request payload ##### Description Get the request's POST payload. ##### Example ```typescript /app/routes/fulfillment_order_notification.ts import { ActionFunction } from "@remix-run/node"; import { authenticate } from "../shopify.server"; export const action: ActionFunction = async ({ request }) => { const { payload } = await authenticate.fulfillmentService(request); if(payload.kind === 'FULFILLMENT_REQUEST') { // handle fulfillment request } else if (payload.kind === 'CANCELLATION_REQUEST') { // handle cancellation request }; return new Response(); ``` * #### Shopify session for the fulfillment service notification request ##### Description Use the session associated with this request. ##### /app/routes/fulfillment\_service\_notification.tsx ```typescript import { ActionFunctionArgs } from "@remix-run/node"; import { authenticate } from "../shopify.server"; export const action = async ({ request }: ActionFunctionArgs) => { const { session, admin } = await authenticate.fulfillmentService(request); console.log(session.id) return new Response(); }; ``` ## Related [Interact with the Admin API. - Admin API context](https://shopify.dev/docs/api/shopify-app-remix/apis/admin-api) [Receive fulfillment requests and cancellations. - Manage Fulfillments](https://shopify.dev/docs/apps/fulfillment/fulfillment-service-apps/manage-fulfillments)