---
title: "Inspection files"
description: "How to create Digiploma inspection files for MEC supervision: signed ArquivoFiscalizacao XML of diplomas issued or registered, of type Issuer or Registry."
canonical: "https://docs.lacunasoftware.com/en-us/articles/digiploma/api/inspection-files"
locale: "en"
product: "Digiploma"
last_updated: "2026-10-11"
---

# Inspection files

When MEC supervises an institution, the institution provides an **inspection file** (*arquivo de fiscalização*): a signed XML file, in the
MEC layout `ArquivoFiscalizacao`, with the diplomas it issued or registered in a period. Digiploma generates and signs this file on
request, for an [institution](https://docs.lacunasoftware.com/en-us/articles/digiploma/api/institutes).

There are two kinds of file:

| `type` | Contents of each diploma entry |
|---|---|
| `Issuer` | Validation code, the holder's CPF, the e-MEC course code, the issue and registration dates, and the URLs of the diploma XML and of the RVDD (and, optionally, of the academic documentation XML). |
| `Registry` | Validation code, the holder's CPF, the issuer's and the course's e-MEC codes, the registration book data and the id of the academic documentation. |

## Create an inspection file

`POST /api/inspection-files` requires the `CreateInspectionFile` permission:

```json
{ "type": "Issuer", "iesCode": 1234, "startDate": "2026-01-01T00:00:00-03:00", "endDate": "2026-06-30T23:59:59-03:00", "includeAcademicRegistryUrl": false }
```

| Field | Required | Description |
|---|---|---|
| `type` | Yes | `Issuer` or `Registry`. Must match the institution's type (`InspectionTypeUnavailableForThisOrganization`). |
| `iesCode` | Yes | The institution's MEC code. |
| `startDate`, `endDate` | Yes | The period. `endDate` must not be earlier than `startDate` (`EndDateMustBeGreaterOrEqual`). |
| `includeAcademicRegistryUrl` | No | `Issuer` only: also include the URL of the academic documentation XML, when MEC asks for it. |

The period selects the diplomas, with both XML files signed, whose **last update** falls in it, including dates `startDate` and `endDate`.

Generation is **asynchronous**: the call returns the file with `status` `Started`. Follow it with `GET /api/inspection-files/{id}` or with
the webhooks below.

The URLs in an `Issuer` file are links to download each diploma's files without authentication. They expire after 14 days by default, so
generate the file when MEC requests it.

## Statuses

| `status` | Meaning |
|---|---|
| `Started` | Being generated. |
| `Created` | Generated and waiting for the signature in Signer (manual signing). |
| `Signed` | Signed and ready to download. |
| `Error` | Generation failed. `errorReason` says why. |

Generation fails with `EmptyInspectionFile` when no diploma matches the period. It can also fail with `UnavailableEmissionAndRegistrationDates`
or `UnavailableRegistrationBook` when some diplomas still lack their registration book entries: Digiploma then schedules their creation, and
you should request a new file a few hours later.

The file is signed like the [lists of annulled diplomas](https://docs.lacunasoftware.com/en-us/articles/digiploma/api/cancellation-lists#signing-and-statuses): automatically with the institution's
e-CNPJ certificate, or manually in Lacuna Signer, according to the institution's settings.

## Operations

| Operation | Description |
|---|---|
| `POST /api/inspection-files` | Create an inspection file. |
| `GET /api/inspection-files?InstituteId={id}` or `?IesCode={code}` | A page of the institution's inspection files, sorted by update date. One of the two filters is required (`InstituteFilterRequired`). |
| `GET /api/inspection-files/{id}` | An inspection file. |
| `GET /api/inspection-files/{id}/xml-ticket` | A [ticket](https://docs.lacunasoftware.com/en-us/articles/digiploma/api#downloads-and-tickets) to download the XML. Fails with `InspectionFileGenerationNotConcluded` while the file is `Started`. |

An inspection file has `id`, `iesCode`, `iesName`, `type`, `startDate`, `endDate`, `status`, `errorReason`, `creationDate`, `updateDate`
and, for manual signing, `signerDocumentId` and `signerDocumentUrl`.

## Webhooks

| Event | When |
|---|---|
| `InspectionFileCreated` | The file was generated and sent to Signer (manual signing). |
| `InspectionFileSigned` | The file was signed. |
| `InspectionFileGenerationError` | Generation failed. `details` has the reason. |

The payload also has the number of diplomas in the file (`inspectedDegreesNumber`). Do not rely on the `InspectionFileStarted` and
`InspectionFileGenerated` events listed in the API reference: they do not mark the start and the end of the generation. See
[Webhooks](https://docs.lacunasoftware.com/en-us/articles/digiploma/api/webhooks).
