5.3 KiB
5.3 KiB
M4 API Catalog (Core Only)
Status: Active
Date: 2026-02-24
Owner: Technical Lead
Environment: dev
Frontend source of truth
Use this file and docs/MILESTONES/M4/planning/m4-core-api-frontend-guide.md for core endpoint consumption.
Related next-slice contract
Verification pipeline design (attire, government ID, certification):
docs/MILESTONES/M4/planning/m4-verification-architecture-contract.md
1) Scope and purpose
This catalog defines the currently implemented core backend contract for M4.
2) Global API rules
- Route group in scope:
/core/*. - Compatibility aliases in scope:
POST /uploadFile->POST /core/upload-filePOST /createSignedUrl->POST /core/create-signed-urlPOST /invokeLLM->POST /core/invoke-llm
- Auth model:
GET /healthis public in dev- all other routes require
Authorization: Bearer <firebase-id-token>
- Standard error envelope:
{
"code": "STRING_CODE",
"message": "Human readable message",
"details": {},
"requestId": "optional-request-id"
}
- Response header:
X-Request-Id
3) Core routes
3.1 Upload file
- Method and route:
POST /core/upload-file - Request format:
multipart/form-data - Fields:
file(required)visibility(publicorprivate, optional)category(optional)
- Accepted types:
application/pdfimage/jpegimage/jpgimage/png
- Max size:
10 MB(default) - Behavior: real upload to Cloud Storage.
- Success
200:
{
"fileUri": "gs://krow-workforce-dev-private/uploads/<uid>/...",
"contentType": "application/pdf",
"size": 12345,
"bucket": "krow-workforce-dev-private",
"path": "uploads/<uid>/...",
"requestId": "uuid"
}
- Errors:
UNAUTHENTICATEDINVALID_FILE_TYPEFILE_TOO_LARGE
3.2 Create signed URL
- Method and route:
POST /core/create-signed-url - Request:
{
"fileUri": "gs://krow-workforce-dev-private/uploads/<uid>/file.pdf",
"expiresInSeconds": 300
}
- Security checks:
- bucket must be allowed
- path must be owned by caller (
uploads/<caller_uid>/...) - object must exist
expiresInSeconds <= 900
- Success
200:
{
"signedUrl": "https://storage.googleapis.com/...",
"expiresAt": "2026-02-24T15:22:28.105Z",
"requestId": "uuid"
}
- Errors:
VALIDATION_ERRORFORBIDDENNOT_FOUND
3.3 Invoke model
- Method and route:
POST /core/invoke-llm - Request:
{
"prompt": "...",
"responseJsonSchema": {},
"fileUrls": []
}
- Behavior:
- real Vertex AI call
- model default:
gemini-2.0-flash-001 - timeout default:
20 seconds
- Rate limit:
20 requests/minuteper user (default)- when exceeded:
429 RATE_LIMITEDandRetry-Afterheader
- Success
200:
{
"result": {},
"model": "gemini-2.0-flash-001",
"latencyMs": 367,
"requestId": "uuid"
}
- Errors:
UNAUTHENTICATEDVALIDATION_ERRORMODEL_TIMEOUTMODEL_FAILEDRATE_LIMITED
3.4 Create verification job
- Method and route:
POST /core/verifications - Auth: required
- Request:
{
"type": "attire",
"subjectType": "worker",
"subjectId": "worker_123",
"fileUri": "gs://krow-workforce-dev-private/uploads/<uid>/file.pdf",
"rules": {}
}
- Behavior:
- validates
fileUriownership - requires file existence when
UPLOAD_MOCK=falseandVERIFICATION_REQUIRE_FILE_EXISTS=true - enqueues async verification
- Success
202:
{
"verificationId": "ver_123",
"status": "PENDING",
"type": "attire",
"requestId": "uuid"
}
- Errors:
UNAUTHENTICATEDVALIDATION_ERRORFORBIDDENNOT_FOUND
3.5 Get verification status
- Method and route:
GET /core/verifications/{verificationId} - Auth: required
- Success
200:
{
"verificationId": "ver_123",
"status": "NEEDS_REVIEW",
"type": "attire",
"requestId": "uuid"
}
- Errors:
UNAUTHENTICATEDFORBIDDENNOT_FOUND
3.6 Review verification
- Method and route:
POST /core/verifications/{verificationId}/review - Auth: required
- Request:
{
"decision": "APPROVED",
"note": "Manual review passed",
"reasonCode": "MANUAL_REVIEW"
}
- Success
200: status becomesAPPROVEDorREJECTED. - Errors:
UNAUTHENTICATEDVALIDATION_ERRORFORBIDDENNOT_FOUND
3.7 Retry verification
- Method and route:
POST /core/verifications/{verificationId}/retry - Auth: required
- Success
202: status resets toPENDING. - Errors:
UNAUTHENTICATEDFORBIDDENNOT_FOUND
3.8 Health
- Method and route:
GET /health - Success
200:
{
"ok": true,
"service": "krow-core-api",
"version": "dev",
"requestId": "uuid"
}
4) Locked defaults
- Validation library:
zod. - Validation schema location:
backend/core-api/src/contracts/. - Buckets:
krow-workforce-dev-publickrow-workforce-dev-private
- Model provider: Vertex AI Gemini.
- Max signed URL expiry:
900seconds. - LLM timeout:
20000ms. - LLM rate limit:
20requests/minute/user. - Verification access mode default:
authenticated. - Verification file existence check default: enabled (
VERIFICATION_REQUIRE_FILE_EXISTS=true). - Verification attire provider default in dev:
vertexwith modelgemini-2.0-flash-lite-001. - Verification government/certification providers: external adapters via configured provider URL/token.