Garment.id
🇮🇩 Indonesian
  • 🇮🇩 Indonesian
  • 🇺🇸 English
Home
Core APITenant APISupport CenterChangelog
Home
Core APITenant APISupport CenterChangelog
Github
Instagram
|
🇮🇩 Indonesian
  • 🇮🇩 Indonesian
  • 🇺🇸 English
🇮🇩 Indonesian
  • 🇮🇩 Indonesian
  • 🇺🇸 English
  1. Home
  • Introduction
  • 01 - Project Structure
  • 02 - Context Boundaries
  • 03 - Central Auth Runtime
  • 04 - Central Billing
  • 05 - Tenant Runtime
  • 06 - FE Integration Contracts
  • 07 - Security, Middleware, and RLS
  • 08 - Events, Jobs, Listeners, Notifications, Observers
  • 09 - Testing and Quality Gates
  • 10 - Operations Runbook
  • 11 - Architecture Decisions (ADR Ringkas)
  • 12 - API Endpoint Catalog (v1)
  • 13 - Class Catalog by Context
  • 14 - Feature Development Playbook
  • 15 - Migration and Model Conventions
  • 16 - Service, Support, and Trait Contracts
  • 17 - Auth Business Scenarios and Decision Tree
  • 18 - Config Reference and Impact
  • 19 - Migration and Model Cookbook
  • 20 - Billing and Provisioning Business Flows
  • 21 - FE Error Handling Matrix
  • 22 - Incident Playbooks
  • 23 - Data Ownership Matrix
  • 24 - Documentation Governance and Changelog
  • 25 - Tenant Authorization Backend Guide
Home
Core APITenant APISupport CenterChangelog
Home
Core APITenant APISupport CenterChangelog
Github
Instagram
|
🇮🇩 Indonesian
  • 🇮🇩 Indonesian
  • 🇺🇸 English
🇮🇩 Indonesian
  • 🇮🇩 Indonesian
  • 🇺🇸 English
  1. Home

06 - FE Integration Contracts

Dokumen kontrak minimal FE terhadap API runtime saat ini.

FE Runtime Topology#

Base Contract#

Base path: /api/v1
Locale:
header Accept-Language: id|en
atau query ?lang=id|en

Response Envelope#

Semua endpoint JSON mengikuti envelope dari ApiResponse:
success: boolean
code: string
message: string
request_id: string
timestamp: string
api_version: string
data: any (opsional)
meta: object (opsional)
errors: object|array (khusus error validasi)
Referensi:
app/Http/Responses/ApiResponse.php
app/Traits/HasApiResponse.php

Auth Headers#

Authorization: Bearer <access_token>
X-Tenant-ID: <uuid> (opsional; wajib match tenant dalam token jika dikirim)

Token Ability Expectations#

Central runtime auth: tenant:access atau platform:access
Tenant route: token tenant-scoped + valid tenant context

FE Auth Lifecycle (Recommended)#

Critical Endpoints For FE#

Auth#

POST /auth/login
POST /auth/refresh
POST /auth/select-tenant
GET /auth/me
POST /auth/logout
Catatan kontrak tenant selection:
Pada response multi-tenant (data.tenants[]), FE dapat memakai pivot.membership_type dan pivot.last_login_at untuk label peran serta informasi "terakhir login" per tenant.

User Runtime#

/user/security/*
/user/sessions*
/user/notifications*

Tenant Runtime#

/tenant/billing/*
/tenant/integrations/*
/tenant/master-data/taxonomies*

GET /auth/me FE Shape#

FE dapat mengandalkan:
current_tenant.id|name|slug (nullable)
authz.roles[]
authz.permissions[]
Contoh:
{
  "success": true,
  "code": "SUCCESS",
  "data": {
    "id": "...",
    "name": "Super Admin",
    "account": { "type": "platform_admin" },
    "current_tenant": { "id": "...", "name": "Garment Indonesia", "slug": "garment-indonesia" },
    "authz": {
      "roles": ["owner", "ppic"],
      "permissions": ["po.create", "po.approve", "mr.read"]
    }
  }
}

Error Handling Contract#

401: unauthenticated / token invalid / session expired
403: ability/context mismatch (tenant token required, step-up missing, forbidden)
422: validation/business rule
429: throttled
FE wajib handle code dari response, bukan hanya HTTP status.

FE Error Strategy (Practical)#

401: clear access token, trigger refresh flow.
401 setelah refresh gagal: logout lokal + redirect login.
403: tampilkan forbidden/feature-denied sesuai code.
422: tampilkan field-level validation dari errors.
gunakan request_id untuk issue tracing ke BE logs.
Diubah pada 2026-03-03 22:25:30
Sebelumnya
05 - Tenant Runtime
Berikutnya
07 - Security, Middleware, and RLS
Built with