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

# KYC Session Expired

> Webhook event fired when a KYC verification session expires before completion

<Info>
  **Event Name:** `kyc_session_expired`
</Info>

<Note>
  This event is emitted when a KYC verification session expires before completion. The session state is `EXPIRED`.
</Note>

## Event Payload

The webhook payload contains the following structure:

<CodeGroup>
  ```json Example Payload (User) theme={null}
  {
    "eventId": "8f85f3fd-4d95-47f9-9eb4-95ef7b9950f1",
    "eventType": "kyc_session_expired",
    "timestamp": "2026-03-17T16:58:41.204Z",
    "data": {
      "sessionId": "b67d60c6-2e30-4e5d-b76d-78bb2f3e2af4",
      "userId": "37caee35-e19b-4d6d-96bb-3c4f33f3dd5b",
      "entityType": "user"
    }
  }
  ```

  ```json Example Payload (Related Party) theme={null}
  {
    "eventId": "6ff6ff9d-0918-4858-86e8-8c12aef6e4b5",
    "eventType": "kyc_session_expired",
    "timestamp": "2026-03-17T17:02:10.088Z",
    "data": {
      "sessionId": "0d050f52-36a1-4bb8-a45d-b89b801d640d",
      "relatedPartyId": "58c4c281-275f-497e-81d5-8bc9975b2380",
      "entityType": "related-party"
    }
  }
  ```
</CodeGroup>

## Field Description

<ParamField path="eventId" type="string" required>
  Unique event identifier (UUID)
</ParamField>

<ParamField path="eventType" type="string" required>
  Event type - always `kyc_session_expired` for this webhook
</ParamField>

<ParamField path="timestamp" type="string" required>
  Event timestamp in ISO 8601 format
</ParamField>

<ParamField path="data" type="object" required>
  Contains the event data
</ParamField>

<ParamField path="data.sessionId" type="string" required>
  Unique KYC session ID (UUID)
</ParamField>

<ParamField path="data.userId" type="string">
  Unique user ID (UUID)
</ParamField>

<ParamField path="data.relatedPartyId" type="string">
  Unique related party ID (UUID)
</ParamField>

<ParamField path="data.entityType" type="string" required>
  Entity type associated with the KYC session. Possible values: `user`, `related-party`
</ParamField>

## Expected Responses

<CardGroup cols={3}>
  <Card title="Success Response" icon="circle-check" color="#16a34a">
    **HTTP 200 OK**

    The webhook was processed successfully.
  </Card>

  <Card title="Client Error" icon="triangle-exclamation" color="#ea580c">
    **HTTP 4xx Status**

    Client-side error. Will not be retried.
  </Card>

  <Card title="Server Error" icon="circle-xmark" color="#dc2626">
    **HTTP 5xx Status**

    Server-side error. Will be retried with exponential backoff.
  </Card>
</CardGroup>

## Implementation Example

<CodeGroup>
  ```javascript Node.js theme={null}
  app.post('/webhooks/ralio', async (req, res) => {
    const { eventType, data } = req.body;

    if (eventType === 'kyc_session_expired') {
      const { sessionId, entityType, userId, relatedPartyId } = data;
      const subjectId = userId ?? relatedPartyId;

      console.log(`KYC session ${sessionId} expired for ${entityType} ${subjectId}`);

      await updateKycSessionStatus(sessionId, 'EXPIRED');

      if (entityType === 'user' && userId) {
        await notifyUserSessionExpired(userId);
      }

      if (entityType === 'related-party' && relatedPartyId) {
        await notifyRelatedPartySessionExpired(relatedPartyId);
      }

      res.status(200).json({ received: true });
    }
  });
  ```

  ```python Python theme={null}
  @app.route('/webhooks/ralio', methods=['POST'])
  def handle_webhook():
      payload = request.get_json()

      if payload['eventType'] == 'kyc_session_expired':
          data = payload['data']
          session_id = data['sessionId']
          entity_type = data['entityType']
          user_id = data.get('userId')
          related_party_id = data.get('relatedPartyId')
          subject_id = user_id or related_party_id

          print(f"KYC session {session_id} expired for {entity_type} {subject_id}")

          update_kyc_session_status(session_id, 'EXPIRED')

          if entity_type == 'user' and user_id:
              notify_user_session_expired(user_id)

          if entity_type == 'related-party' and related_party_id:
              notify_related_party_session_expired(related_party_id)

          return jsonify({'received': True}), 200
  ```

  ```go Go theme={null}
  func handleWebhook(w http.ResponseWriter, r *http.Request) {
      var payload struct {
          EventType string `json:"eventType"`
          Data  struct {
              SessionID      string `json:"sessionId"`
              UserID         string `json:"userId"`
              RelatedPartyID string `json:"relatedPartyId"`
              EntityType     string `json:"entityType"`
          } `json:"data"`
      }

      if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
          http.Error(w, "Invalid JSON", http.StatusBadRequest)
          return
      }

      if payload.EventType == "kyc_session_expired" {
          subjectID := payload.Data.UserID
          if subjectID == "" {
              subjectID = payload.Data.RelatedPartyID
          }

          log.Printf("KYC session %s expired for %s %s", payload.Data.SessionID, payload.Data.EntityType, subjectID)

          if err := updateKycSessionStatus(payload.Data.SessionID, "EXPIRED"); err != nil {
              http.Error(w, "Internal error", http.StatusInternalServerError)
              return
          }

          if payload.Data.EntityType == "user" && payload.Data.UserID != "" {
              if err := notifyUserSessionExpired(payload.Data.UserID); err != nil {
                  http.Error(w, "Internal error", http.StatusInternalServerError)
                  return
              }
          }

          if payload.Data.EntityType == "related-party" && payload.Data.RelatedPartyID != "" {
              if err := notifyRelatedPartySessionExpired(payload.Data.RelatedPartyID); err != nil {
                  http.Error(w, "Internal error", http.StatusInternalServerError)
                  return
              }
          }

          w.Header().Set("Content-Type", "application/json")
          w.WriteHeader(http.StatusOK)
          json.NewEncoder(w).Encode(map[string]bool{"received": true})
      }
  }
  ```
</CodeGroup>
