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

# Affiliate Quickstart

> List activities, create a booking, and process payment in four steps.

Affiliates use the Seyaha API to present activities to end users, handle bookings,
and process payments (Moyasar or Stripe) — all via JWT authentication.

<Steps>
  <Step title="Get a JWT">
    Affiliates authenticate with a JWT issued by Seyaha. Obtain yours through the
    affiliate onboarding flow or contact `tech@seyaha.net` to provision credentials.

    Include the JWT in every request:

    ```http theme={null}
    Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
    ```
  </Step>

  <Step title="Browse activities">
    Fetch available activities for your user:

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://api.seyaha.net/api/v1/affiliates/users/activities?currency=SAR&page=1&pageSize=10" \
        -H "Authorization: Bearer $AFFILIATE_JWT"
      ```

      ```javascript Node.js theme={null}
      const params = new URLSearchParams({ currency: 'SAR', page: '1', pageSize: '10' });
      const res = await fetch(
        `https://api.seyaha.net/api/v1/affiliates/users/activities?${params}`,
        { headers: { 'Authorization': `Bearer ${affiliateJwt}` } }
      );
      const { data, pagination } = await res.json();
      ```
    </CodeGroup>
  </Step>

  <Step title="Create a booking">
    When the user chooses an activity and time, create a booking:

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST https://api.seyaha.net/api/v1/affiliates/users/add-booking \
        -H "Authorization: Bearer $AFFILIATE_JWT" \
        -H "Content-Type: application/json" \
        -d '{
          "activity_id": "6744810075becd2ef8c140f7",
          "variation_id": "6751ad2d7533f379c9a1711b",
          "customer_details": {
            "name": "Ahmed Al-Rashid",
            "email": "ahmed@example.com",
            "phone": "+966501234567"
          },
          "booking_details": {
            "booking_date": "2026-07-15",
            "booking_time": "10:00",
            "currency": "SAR",
            "guests": { "adult": 2, "child": 0, "infant": 0, "senior": 0 }
          }
        }'
      ```

      ```javascript Node.js theme={null}
      const res = await fetch(
        'https://api.seyaha.net/api/v1/affiliates/users/add-booking',
        {
          method: 'POST',
          headers: {
            'Authorization': `Bearer ${affiliateJwt}`,
            'Content-Type': 'application/json',
          },
          body: JSON.stringify({
            activity_id: activityId,
            variation_id: varId,
            customer_details: { name: 'Ahmed Al-Rashid', email: 'ahmed@example.com', phone: '+966501234567' },
            booking_details: { booking_date: '2026-07-15', booking_time: '10:00', currency: 'SAR', guests: { adult: 2, child: 0, infant: 0, senior: 0 } },
          }),
        }
      );
      const { data: booking } = await res.json();
      // booking.status === 'Booking Attempt'
      ```
    </CodeGroup>
  </Step>

  <Step title="Process payment">
    Initiate payment using Moyasar or Stripe. On success, booking status moves to
    `Paid by Customer` automatically.

    <CodeGroup>
      ```bash cURL (Moyasar) theme={null}
      curl -X POST https://api.seyaha.net/api/v1/affiliates/create-payment \
        -H "Authorization: Bearer $AFFILIATE_JWT" \
        -H "Content-Type: application/json" \
        -d '{
          "callback_url": "https://yourapp.com/payment/callback",
          "method": "Moyasar",
          "source": {
            "type": "creditcard",
            "name": "Ahmed Al-Rashid",
            "number": "4111111111111111",
            "cvc": "123",
            "month": "07",
            "year": "28"
          },
          "meta_data": { "booking_id": "67c896a6639e6ff76dd2f882" }
        }'
      ```

      ```bash cURL (Stripe) theme={null}
      curl -X POST https://api.seyaha.net/api/v1/affiliates/create-payment \
        -H "Authorization: Bearer $AFFILIATE_JWT" \
        -H "Content-Type: application/json" \
        -d '{
          "callback_url": "https://yourapp.com/payment/callback",
          "method": "Stripe",
          "meta_data": { "booking_id": "67c896a6639e6ff76dd2f882" }
        }'
      ```

      ```javascript Node.js theme={null}
      const res = await fetch(
        'https://api.seyaha.net/api/v1/affiliates/create-payment',
        {
          method: 'POST',
          headers: {
            'Authorization': `Bearer ${affiliateJwt}`,
            'Content-Type': 'application/json',
          },
          body: JSON.stringify({
            callback_url: 'https://yourapp.com/payment/callback',
            method: 'Stripe',
            meta_data: { booking_id: bookingId },
          }),
        }
      );
      const { data: payment } = await res.json();
      // For Stripe: redirect user to payment.source.transaction_url
      window.location.href = payment.source.transaction_url;
      ```
    </CodeGroup>

    For Stripe, redirect the user to `data.source.transaction_url`. For Moyasar
    credit card, a `transaction_url` is returned only when 3DS is required.
  </Step>
</Steps>

## What's next

* [Activities](/pages/affiliate/activities) — search, filter, and currency options
* [Bookings](/pages/affiliate/bookings) — full booking and payment reference
