offline_at, and is idempotent by offline_id: an operation already processed successfully is answered from the cache without running again. A failed operation does not stop the rest of the batch, and the request answers 200 whatever the outcome of the single operations.quiz_submit, exam_submit, dive_log_create and skills_sign are processed.dive_log_create operation is validated with the same rule set as POST /api/v1/diver/dive-logs (CreateDiveLogRequest::rulesFor()) and creates the row through the same action as that endpoint.App\Http\Controllers\Api\V1\Sync\SyncController::upload()api.v1.sync.uploadAuthorization: Bearer {token}POST/api/v1/sync/uploadapplication/json{
"operations": [
{
"type": "dive_log_create",
"offline_id": "d1f0c8a2-0001",
"offline_at": "2026-09-17T10:00:01+00:00",
"data": {
"date": "2026-09-17 09:00:00",
"dive_config": "open_circuit",
"dive_type": "shore",
"location": "Example Sync Site",
"country": "IT",
"dive_time": 45,
"max_depth": 18,
"average_depth": 12,
"is_free_diving": false,
"purpose_type": "fun_dive",
"dive_number": 1,
"gas": "nitrox",
"gas_mix": { "oxygen": 32, "nitrogen": 68, "helium": 0 },
"abt": 40,
"rnt": 5,
"tbt": 45
}
},
{
"type": "skills_sign",
"offline_id": "d1f0c8a2-0002",
"offline_at": "2026-09-17T10:00:02+00:00",
"data": {
"log_code": "9d3f6a1b2c4e4f7a8b0c1d2e3f4a5b6c",
"signatures": [
{ "skill_log_id": 930001, "skills": { "5001": true, "5002": false } }
]
}
},
{
"type": "quiz_submit",
"offline_id": "d1f0c8a2-0003",
"offline_at": "2026-09-17T10:00:03+00:00",
"data": {
"log_code": "9d3f6a1b2c4e4f7a8b0c1d2e3f4a5b6c",
"module_id": 9101,
"answers": { "7121": 27632 }
}
},
{
"type": "exam_submit",
"offline_id": "d1f0c8a2-0004",
"offline_at": "2026-09-17T10:00:04+00:00",
"data": {
"log_code": "9d3f6a1b2c4e4f7a8b0c1d2e3f4a5b6c",
"answers": { "7001": 9001 }
}
}
]
}App\Http\Requests\Api\V1\Sync\SyncUploadRequest.| Field | Type | Required | Validation | Description |
|---|---|---|---|---|
operations | array | Yes | required|array|min:1 | List of offline operations |
operations[].type | string | Yes | required|string|in:quiz_submit,exam_submit,dive_log_create,skills_sign | Operation type |
operations[].offline_id | string | Yes | required|string|max:100 | Client-generated unique id, the idempotency key |
operations[].offline_at | datetime | Yes | required|date | When the operation was performed offline. Sets the processing order |
operations[].data | object | Yes | required|array | Operation payload, see below |
data is not validated by the request. Each operation reads what it needs from it.dive_log_createPOST /api/v1/diver/dive-logs, validated with the same rules. See docs/api/diver/dive-logs/POST_create.md for the field table, the accepted enum values, the group letters A-Z, the gas_mix keys and the course_log rules. A payload that the create endpoint would refuse is refused here too, with the field errors in the result's errors. safety_stop and has_decompression default to false when omitted, as on the create endpoint. lat and lon are accepted under the same pairing and range rules as on the create endpoint (both or neither, lat -90 to 90, lon -180 to 180). is_free_diving must agree with dive_config, as on the create endpoint.skills_sign| Field | Description |
|---|---|
log_code | Course log code of the caller. An unknown code, or one that belongs to another user, gives Course log not found |
signatures | Array of {skill_log_id, skills}, where skills is a map {skill id: bool} that replaces the stored user_skills wholesale |
quiz_submitModule not found), when the log is locked by admin_lock or quiz_lock (Quiz is locked), when an attempt with the same start was already submitted for the module (Quiz already submitted; without start only offline_id idempotency applies), and when answers is empty, holds more questions than the module's quiz_questions or a question outside the module's quiz pool (Invalid answers). Scored like POST /api/v1/diver/courses/{log_code}/modules/{module}/quiz: total is the module's quiz_questions and the quiz passes when the correct answers reach its quiz_minimum. The quiz row is dated with the operation's offline_at; the failed-attempt lock and the completion mail to the instructor apply as on the REST endpoint.| Field | Description |
|---|---|
log_code | Course log code |
module_id | Module id, from GET /api/v1/sync/download |
answers | Map {question id: answer id} |
start, end | Optional timestamps |
exam_submitadmin_lock) needs proof of the instructor's unlock: unlock_code (the value scanned from the instructor's QR code) and unlocked_at (when the app checked it), see GET /api/v1/sync/download. In order: a missing or non-string unlock_code gives Unlock code required; a log without instructor, or a code the server does not recompute for the instructor, gives Invalid unlock code; an unlocked_at that is missing, not a date-time or later than the operation's offline_at gives Invalid unlock time. On a match the exam is accepted and, in the same transaction, the log is unlocked (exam_enable true, admin_lock false, admin_lock_comment cleared) and the event is written to the activity log. A log that is not locked ignores both fields. A log with admin_lock false and exam_enable false, whose exam the instructor never enabled, is refused with Exam is not available. Any refusal (same attempt sent twice, invalid answers, not enabled, unlock proof) leaves the log unchanged. Scored like POST /api/v1/diver/courses/{log_code}/exam: every submitted question must be in the log's exam pool for its course version and answers holds at most the course's exam_questions questions, total is the course's exam_questions, and the exam passes when the correct answers reach the course's exam_minimum. The exam row is dated with the operation's offline_at.| Field | Description |
|---|---|
log_code | Course log code |
answers | Map {question id: answer id} |
unlock_code | String. Required when the log is locked by the server: the instructor's unlock code the app scanned |
unlocked_at | Date-time. Required when the log is locked by the server: when the app checked the code, not later than offline_at |
start, end | Optional timestamps |
data: {id, score, passed}. A question id outside the pool, more questions than the course's exam_questions, or an empty answers, gives Invalid answers. An attempt with the same start already submitted for the log (the same attempt sent twice) gives Exam already submitted; without start only offline_id idempotency applies.200 OK200 even when operations fail: look at status in each result.{
"success": true,
"status": "success",
"message": "OK",
"data": {
"processed": 4,
"results": [
{
"offline_id": "d1f0c8a2-0001",
"type": "dive_log_create",
"status": "success",
"data": { "id": 930101 }
},
{
"offline_id": "d1f0c8a2-0002",
"type": "skills_sign",
"status": "success",
"data": { "log_code": "9d3f6a1b2c4e4f7a8b0c1d2e3f4a5b6c", "signed": 1 }
},
{
"offline_id": "d1f0c8a2-0003",
"type": "quiz_submit",
"status": "success",
"data": { "id": 1582901, "score": 100, "passed": true }
},
{
"offline_id": "d1f0c8a2-0004",
"type": "exam_submit",
"status": "success",
"data": { "id": 930201, "score": 80, "passed": true }
}
]
}
}| Field | Type | Nullable | Always present | Description |
|---|---|---|---|---|
data.processed | integer | No | Yes | Number of results, equal to the number of operations sent |
data.results | array | No | Yes | One result per operation, in processing order (offline_at), not in the order sent |
data.results[].offline_id | string | No | Yes | The client id, echoed back |
data.results[].type | string | No | Yes | Operation type |
data.results[].status | string | No | Yes | success or error |
data.results[].data | object | No | On success | {id} for dive_log_create, {log_code, signed} for skills_sign, {id, score, passed} for quiz_submit and exam_submit. signed counts the signatures submitted, not the ones applied |
data.results[].error | string | No | On error | Message, see below |
data.results[].errors | object | No | Only on a dive_log_create that failed validation | Field errors, keyed by field name with an array of messages, the map the create endpoint returns |
error valueserror | Meaning |
|---|---|
Validation failed | dive_log_create payload refused by the create rules; the detail is in errors |
Invalid country code | dive_log_create with a country that does not resolve |
Course log not found | skills_sign, quiz_submit, exam_submit with a log_code that is unknown or not the caller's |
Unlock code required | exam_submit on a log locked by the server without a string unlock_code |
Invalid unlock code | exam_submit on a locked log without instructor, or with a code that does not match the instructor's |
Invalid unlock time | exam_submit on a locked log with a missing, unparseable or later-than-offline_at unlocked_at |
Exam is not available | exam_submit on a log whose exam the instructor never enabled (admin_lock false and exam_enable false) |
Quiz is locked | quiz_submit on a log with admin_lock or quiz_lock |
Quiz is not available for a repetition | quiz_submit on a log that is a repetition of an already certified course; nothing is written |
Exam is not available for a repetition | exam_submit on a log that is a repetition of an already certified course; nothing is written |
Skills are not available for a repetition | skills_sign on a log that is a repetition of an already certified course; nothing is written |
Invalid answers | exam_submit or quiz_submit with no answers, more answers than the exam or quiz asks, or a question id outside the pool |
Exam already submitted | exam_submit when an attempt with the same start was already submitted (the same attempt sent twice) |
Module not found | quiz_submit with a module that is unknown or not of the log's course and course version |
Quiz already submitted | quiz_submit when an attempt with the same start was already submitted (the same attempt sent twice) |
The operation could not be processed | An unexpected failure while processing the operation. The cause is logged on the server and never returned. |
401 Unauthorized{
"success": false,
"status": "error",
"message": "Unauthenticated"
}message is Token expired or Invalid token when a bearer token was sent but is expired or unknown.422 Unprocessable Entity - malformed batchoperations missing or empty, an unknown type, a missing offline_id, offline_at or data) is refused as a whole, before any operation runs. Emitted by ApiFormRequest::failedValidation(). Captured live with an empty body.{
"success": false,
"status": "error",
"message": "Validation failed",
"errors": {
"operations": ["The operations field is required."]
}
}429 Too Many Requestsx-ratelimit-limit: 120. The body is the standard envelope with message: "Too many requests" and a Retry-After header.offline_processed:{user_id}:{offline_id} for 30 days. If the same offline_id is sent again, the cached result is returned and the operation does not run again.offline_id per operation, for example a UUID generated on the device.offline_id runs again.offline_id.offline_at. The results array follows that order.offline_at order.skills_sign writes user_skills, user_ip (the literal offline) and end (the processing time) on each matched skill log, and updated_at moves with them. A skill_log_id that does not exist or belongs to another log_code is skipped without error, and still counts in signed.dive_log_create runs the same action as POST /api/v1/diver/dive-logs, including the reordering of the diver's dive numbers.docs/api/sync/POST_upload.mdcurl --location 'https://test.diveraid.com/api/v1/sync/upload' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"operations": [
{
"type": "quiz_submit",
"offline_id": "string",
"offline_at": "2019-08-24T14:15:22.123Z",
"data": {}
}
]
}'{
"status": "success",
"message": "string",
"data": {
"processed": 0,
"results": [
{
"offline_id": "string",
"type": "string",
"status": "success",
"data": {},
"error": "string",
"errors": {
"property1": [
"string"
],
"property2": [
"string"
]
}
}
]
}
}