Dokumente

Reisedokumente und offizielle Dokumente eines Crew-Mitglieds abrufen.

Read-only Endpoint

Dokumente können aktuell nur gelesen, nicht via API hochgeladen werden. Der Upload erfolgt über die AeroHR-Oberfläche oder via SFTP-Import.

Dokument-Objekt

FeldTypPflichtBeschreibung
idintegerOptionalEindeutige Dokument-ID
typeenumOptionalpassport | visa | national_id | residence_permit | certificate
namestringOptionalDokumentenbezeichnungz.B. Reisepass DE
numberstringOptionalDokumentennummerz.B. C01X00T47
countrystringOptionalAusstellendes Land (ISO 3166-1 alpha-2)
issued_datedateOptionalAusstellungsdatum
expiry_datedate|nullOptionalAblaufdatum
statusenumOptionalvalid | expiring_soon | expired
days_until_expiryinteger|nullOptionalVerbleibende Tage bis Ablauf

GET /crew/{id}/documents

GEThttps://api.aeroselect.io/api/v1/crew/crew/{id}/documents
cURLBash
curl "https://api.aeroselect.io/api/v1/crew/crew/201/documents" \
  -H "X-API-Key: ak_live_YOUR_KEY"
Response 200JSON
{
  "data": [
    {
      "id": 701,
      "type": "passport",
      "name": "Reisepass Deutschland",
      "number": "C01X00T47",
      "country": "DE",
      "issued_date": "2022-03-15",
      "expiry_date": "2032-03-14",
      "status": "valid",
      "days_until_expiry": 2122
    },
    {
      "id": 702,
      "type": "visa",
      "name": "US B1/B2 Visa",
      "number": "US2024-88123",
      "country": "US",
      "issued_date": "2024-01-10",
      "expiry_date": "2034-01-09",
      "status": "valid",
      "days_until_expiry": 2788
    }
  ]
}

Auslaufende Dokumente überwachen

document-expiry-check.jsJavaScript
// Alle Crew-Mitglieder auf ablaufende Dokumente prüfen
async function checkExpiringDocuments(crewIds, warningDays = 90) {
  const expiringDocs = [];

  for (const crewId of crewIds) {
    const response = await fetch(
      `https://api.aeroselect.io/api/v1/crew/crew/${crewId}/documents`,
      { headers: { "X-API-Key": process.env.AEROSELECT_API_KEY } }
    );
    const { data: docs } = await response.json();

    for (const doc of docs) {
      if (
        doc.days_until_expiry !== null &&
        doc.days_until_expiry <= warningDays
      ) {
        expiringDocs.push({ crew_id: crewId, ...doc });
      }
    }
  }

  return expiringDocs.sort(
    (a, b) => (a.days_until_expiry ?? 0) - (b.days_until_expiry ?? 0)
  );
}