Skip to content
Andreas Michael edited this page Dec 2, 2026 · 2 revisions

API & Hooks

This reference documents the HTTP/JSON API endpoints and Drupal hooks exposed by the ESN Membership Manager module.

REST / JSON API Endpoints

Endpoints authenticated with oauth2 or cookie require a valid X-CSRF-Token header (when using cookie auth) or an OAuth2 Bearer token (e.g., from the Scanner app using scope omnia_scanner_esn_membership_manager / esn_scanner).

Scanner & Membership Operations

Method Path Auth / Permission Description
GET /api/memberships/online Public Health/connectivity check for the Scanner app.
POST /api/memberships/scan oauth2/cookie + scan cards Validates an ESNcard (^\d{7}[A-Z]{3}[A-Z0-9]$), Free Pass (^[A-F0-9]{32}$), or Guest Pass (^GUEST[A-F0-9]{27}$). Updates date_last_scanned (or marks Guest Pass as redeemed).
POST /api/memberships/add oauth2/cookie + manage esncard numbers Adds an ESNcard number to inventory and fulfills any backlogged application.
POST /api/memberships/status oauth2/cookie + per-action permission Transitions an application's status (Approved, Rejected with optional -Category-Issue codes, Paid, Issued, Delivered, Blacklisted) by id or card.
POST /api/memberships/edit oauth2/cookie + edit applications Updates editable fields on an application and triggers Wallet pass updates.
POST /api/memberships/edit/crop oauth2/cookie + edit applications Saves a base64-encoded cropped face photo for an application.

Example: Scan Request & Response (POST /api/memberships/scan)

Request:

{
  "card": "A1B2C3D4E5F67890123456789ABCDEF0"
}

Response (ESNcard / Free Pass):

{
  "name": "Jane",
  "surname": "Doe",
  "nationality": "Cypriot",
  "mobilityStatus": "Erasmus+ Student",
  "datePaid": "2026-09-15",
  "dateApproved": "2026-09-14",
  "lastScanDate": null,
  "profileImageURL": "https://your-domain.com/memberships/files/42/face.jpg"
}

Response (Guest Pass):

{
  "name": "John",
  "surname": "Smith",
  "refererName": "Jane",
  "refererSurname": "Doe",
  "refererMobilityStatus": "Erasmus+ Student",
  "dateApproved": "2026-10-01",
  "dateRedeemed": null
}

Email Authentication Endpoints

Method Path Auth Description
POST /api/memberships/auth/{type}/code Public Generates and emails an 8-digit verification code (register or login).
POST /api/memberships/auth/{type}/verify Public Verifies the 8-digit code and establishes an authenticated session.

External Webhooks & Callbacks

Method Path Purpose
POST /stripe/webhook Handles Stripe checkout.session.completed webhooks.
GET /memberships/apply/verify/id Didit ID verification callback (verificationSessionId).
GET /memberships/apply/verify/esn-accounts ESN Accounts CAS validation callback (ticket, token).
GET /memberships/auth/google Google OAuth2 callback.
GET/POST /memberships/auth/apple Sign in with Apple callback.
GET /admin/config/system/esn-membership-manager/weeztix-auth-callback Weeztix OAuth2 callback (manage module settings).

Apple Wallet Web Service Protocol

Implements Apple's PassKit Web Service for live pass updates (authenticated via Authorization: ApplePass <sha256(serialNumber + hash_salt)>):

POST / DELETE /api/apple-wallet/v1/devices/{deviceLibraryIdentifier}/registrations/{passTypeIdentifier}/{serialNumber}

Register/unregister a device for push updates.

  • GET /api/apple-wallet/v1/devices/{deviceLibraryIdentifier}/registrations/{passTypeIdentifier}

    List serial numbers updated since passesUpdatedSince.

  • GET /api/apple-wallet/v1/passes/{passTypeIdentifier}/{serialNumber}

    Download the latest .pkpass bundle.

  • POST /api/apple-wallet/v1/log

    Flood-protected device error logging.


Drupal Hooks Implemented

Defined in esn_membership_manager.module:

  • esn_membership_manager_theme():

    Registers Twig templates for all 11 email types (via EmailService::processHookTheme()), emm_application_view, and emm_esncard.

  • esn_membership_manager_mail():

    Delegates email formatting to Omnia's EmailService::processHookMail().

  • esn_membership_manager_file_download():

    Enforces view applications permission with Cache-Control: privatefor all membership:// URIs.

  • esn_membership_manager_cron():

    Executes esn_membership_manager.cron_service (GDPRCron).

  • esn_membership_manager_simple_oauth_private_claims_alter():

    Injects the user's display name and grantedesn_membership_manager permissions array into Simple OAuth JWT access tokens for the Scanner app.

  • esn_membership_manager_preprocess_page():

    Hides breadcrumbs on the /memberships/apply route.

  • esn_membership_manager_preprocess_menu():

    Flattens the Membership main menu category into a single top-level Membership Form link for users who only have access to apply.


Alter Hooks Exposed

  • hook_membership_dashboard_section_info_alter(array &$definitions):

    Invoked by DashboardSectionManager (plugin.manager.membership_dashboard_section) when building cached #[DashboardSection]plugin definitions, allowing modules to reorder section weights, override sidebar icons/labels, or remove sections. See Dashboard Extensions for details.

Clone this wiki locally