Skip to main content
Some API resources may have relationships with files. Examples may be:
  • a user picture ;
  • a work-contract attachment ;
  • etc…
1

Upload a file

First upload a file through the file-upload API endpoint.
POST /lucca-files/api/uploads HTTP/1.1
Host: example.ilucca.net
Authorization: lucca application={API_KEY}
Accept: application/json
Content-Type: multipart/form-data; boundary=---abc

-----abc
Content-Disposition: form-data; name=""; filename="test.pdf"

-----abc--
curl --location 'https://example.ilucca.net/lucca-files/api/uploads' \
--header 'Authorization: lucca application={API_KEY}' \
--header 'Accept: application/json' \
--form '=@"/C:/foo/bar/test.pdf"'
{
    "id": "d18261af-3b70-442f-94c2-3995cc8ca02c",
    "name": "test.pdf",
    "createdAt": "2024-11-21T14:54:14.1273553Z",
    "deletedAt": null,
    "contentLength": 3242,
    "contentType": "application/pdf",
    "extension": ".pdf",
    "totalPages": 1
}
Make sure to keep the id given in the response, you’ll need it later.
2

Set the file id as a reference on the object

You then need to set the uploaded file id on the corresponding resource.
PUT /api/v3/users/416 HTTP/1.1
Host: example.ilucca.net
Authorization: lucca application={API_KEY}
Accept: application/json
Content-Type: application/json

{
    "picture": {
        "id": "618d5bac-2f38-4d5b-8ba3-981733dffeff"
    }
}
PUT /api/v3/users/:idUser?fields=extendedData,id HTTP/1.1
Host: example.ilucca.net
Authorization: lucca application={API_KEY}
Accept: application/json
Content-Type: application/json

{
    "e_Visite-medicale": [
        {
        "value": {
            "e_Date-de-la-visite": { "value": null },
            "e_Attestation": {
            "value": { "id": "552cb7db-b7e2-4f39-a675-c4b140f41eea" } // File id
            },
            "e_Convocation": { "value": null },
            "e_Date-de-la-prochaine-visite": { "value": null },
            "e_Preconisations-medicales": { "value": null }
        },
        "isNew": true,
        "id": 0
        }
    ]
}