# Emissione - API ex-ante/direct

ex-ante/direct vuol dire, come già detto, che occorre fornire in fase di emissione tutte le info relative all'identificazione del titolare e tutti i dati necessari per emettere il certificato.

#### **Chiamata di apertura richiesta di certificato**

Per aprire una richiesta di certificato occorre chiamare il servizio:

<p class="callout info">[Apertura richiesta ex-ante](https://ca-test.agyo.io/openapi/swagger-ui/index.html?urls.primaryName=certificate-lifecycle#/certificate-api-controller/openExAnte "Apertura richiesta ex-ante")</p>

Nella chiamata occorre passare diverse informazioni:

```json
{
  "profile": "string",
  "rao": {
    "certificateAlias": "string",
    "alias": "string"
  },
  "organization": {
    "name": "string",
    "unit": "string",
    "identifier": "string",
    "country": "string",
    "city": "string",
    "district": "string",
    "cap": "string",
    "address": "string",
    "email": "string",
    "processApplication": "string",
    "responsibleDocument": "string",
    "responsiblePosition": "string"
  },
  "owner": {
    "alias": "string",
    "firstName": "string",
    "lastName": "string",
    "sex": "string",
    "birthCity": "string",
    "birthCountry": "string",
    "birthDate": "2023-07-02",
    "birthDistrict": "string",
    "city": "string",
    "country": "string",
    "district": "string",
    "cap": "string",
    "address": "string",
    "email": "string",
    "phoneNumber": "string",
    "pec": "string",
    "fiscalCode": "string",
    "document": {
      "issuer": "string",
      "country": "string",
      "number": "string",
      "releaseDate": "2023-07-02",
      "expiryDate": "2023-07-02",
      "type": "IDC"
    }
  }
}
```

- **profile** è il nome del profilo di emissione. Contiene tutte le informazioni relative al tipo di certificato, all'identificazione richiesta, alla durata, alle possibili modalità di identificazione, al fatto che richieda o meno un pin etc...
- **rao** è il Registration Authority Officer, cioè la persona che si assume la responsabilità di emettere il certificato. Normalmente è un rappresentate del cliente. E' necessario fornire il suo alias(identificativo), mentre l'alias del certificato è opzionale. Ha senso solo se il RAO ha più di un certificato associato.
- **owner** è il titolare del certificato
- **organization** è l'organizzazione (azienda) per la quale il titolare lavora/opera. Obbligatorio nel caso di emissione di sigilli.

Il servizio esegue una validazione molto stringente dei valori forniti:

<table border="1" id="bkmrk-nome-obbligatorio-re" style="border-collapse: collapse; width: 100%; height: 899px;"><tbody><tr style="height: 29px;"><td class="align-center" style="width: 24.4444%; height: 29px;">**nome**</td><td class="align-center" style="width: 12.9632%; height: 29px;">**obbligatorio**</td><td class="align-center" style="width: 19.1357%; height: 29px;">**regex**</td><td class="align-center" style="width: 10.1235%; height: 29px;">**condizioni**</td><td class="align-center" style="width: 16.6667%; height: 29px;">**dipendenze**</td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.firstName</td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">\[\\w\\s\]{1,128} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.lastName </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">\[\\w\\s\]{1,128} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.sex </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">\[FMfm\]{1} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.birthCity </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">ricavato dal servizio messo a disposizione dalla CA</td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.birthCountry </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">iso alpha 2 </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.birthdate </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">yyyy-MM-dd </td><td class="align-center" style="width: 10.1235%; height: 29px;">&gt;=18 &amp;&amp; &lt;=120 anni</td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.birthDistrict </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">ricavato dal servizio messo a disposizione dalla CA</td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.city </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">ricavato dal servizio messo a disposizione dalla CA</td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.country </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">iso alpha 2 </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.district </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">ricavato dal servizio messo a disposizione dalla CA</td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.cap</td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">\[0-9\]{3,10} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.address </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">\[\\w\\s\]{1,128} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.email </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">si applica reg exp relativa alla mail</td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.pec </td><td class="align-center" style="width: 12.9632%; height: 29px;"> </td><td class="align-center" style="width: 19.1357%; height: 29px;">si applica reg exp relativa alla mail</td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.phone </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">\[+0-9\]{8,15} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">owner.fiscalNumber </td><td class="align-center" style="width: 12.9632%; height: 29px;"> </td><td class="align-center" style="width: 19.1357%; height: 29px;">codice fiscale valido e ricavabile dai valori precedenti</td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">document.issuer </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">\[\\w\\s\]{1,128} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">document.country </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">iso alpha 2 </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">document.number </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">si applica reg exp relative al numero di documento</td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">document.releaseDate</td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">yyyy-MM-dd </td><td class="align-center" style="width: 10.1235%; height: 29px;">&lt;=oggi </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">document.expiryDate </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">yyyy-MM-dd </td><td class="align-center" style="width: 10.1235%; height: 29px;">&gt;oggi </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">document.type </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">IDC|PAS|DLC</td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;">Se fiscalNumber non fornito il type potrà essere solo PAS</td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">organization.name </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">\[\\w\\s\]{1,128} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;">obbligatorio solo per certificati di tipo SEAL</td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">organization.unit </td><td class="align-center" style="width: 12.9632%; height: 29px;"> </td><td class="align-center" style="width: 19.1357%; height: 29px;">\[\\w\\s\]{1,128} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">organization.identifier </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">\[\\w\\s\]{1,128} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;">obbligatorio solo per certificati di tipo SEAL</td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">organization.country </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">iso alpha 2 </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;">obbligatorio solo per certificati di tipo SEAL</td></tr><tr><td style="width: 24.4444%;">organization.city</td><td class="align-center" style="width: 12.9632%;">x</td><td class="align-center" style="width: 19.1357%;">ricavato dal servizio messo a disposizione dalla CA</td><td style="width: 10.1235%;">  
</td><td style="width: 16.6667%;">obbligatorio solo per certificati di tipo SEAL</td></tr><tr><td style="width: 24.4444%;">organization.district</td><td class="align-center" style="width: 12.9632%;">x</td><td class="align-center" style="width: 19.1357%;">ricavato dal servizio messo a disposizione dalla CA</td><td style="width: 10.1235%;">  
</td><td style="width: 16.6667%;">obbligatorio solo per certificati di tipo SEAL</td></tr><tr><td style="width: 24.4444%;">organization.cap</td><td class="align-center" style="width: 12.9632%;">x</td><td class="align-center" style="width: 19.1357%;">\[0-9\]{3,10} </td><td style="width: 10.1235%;">  
</td><td style="width: 16.6667%;">obbligatorio solo per certificati di tipo SEAL</td></tr><tr><td style="width: 24.4444%;">organization.address</td><td class="align-center" style="width: 12.9632%;">x</td><td class="align-center" style="width: 19.1357%;">\[\\w\\s\]{1,128} </td><td style="width: 10.1235%;">  
</td><td style="width: 16.6667%;">obbligatorio solo per certificati di tipo SEAL</td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">organization.email </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">si applica reg exp relativa alla mail</td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;">obbligatorio solo per certificati di tipo SEAL</td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">organization.processApplication </td><td class="align-center" style="width: 12.9632%; height: 29px;">x</td><td class="align-center" style="width: 19.1357%; height: 29px;">\[\\w\\s\]{1,128} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;">obbligatorio solo per certificati di tipo SEAL</td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">organization.responsibleDocument </td><td class="align-center" style="width: 12.9632%; height: 29px;"> </td><td class="align-center" style="width: 19.1357%; height: 29px;">\[\\w\\s\]{1,128} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr><tr style="height: 29px;"><td style="width: 24.4444%; height: 29px;">organization.responsiblePosition </td><td class="align-center" style="width: 12.9632%; height: 29px;"> </td><td class="align-center" style="width: 19.1357%; height: 29px;">\[\\w\\s\]{1,128} </td><td class="align-center" style="width: 10.1235%; height: 29px;"> </td><td class="align-center" style="width: 16.6667%; height: 29px;"> </td></tr></tbody></table>

<div id="bkmrk-dove%3A-requestid-%C3%A8-l%27"><div>  
</div></div>#### **Chiamata di completamento richiesta di certificato**

Per completare una richiesta di certificato occorre chiamare il servizio:

<p class="callout info">[Completamento richiesta ex-ante](https://ca-test.agyo.io/openapi/swagger-ui/index.html?urls.primaryName=certificate-lifecycle#/certificate-api-controller/createExAnte "Completamento richiesta ex-ante")</p>

Il servizio può essere invocato solo con un token TSID di tipo API dello stesso cliente che ha aperto la richiesta.

Nella chiamata occorre passare diverse informazioni:

```JSON
{
    "rao": {
        "certificatePin": "12345678"
    },
    "identificationProcess":"VIDEO",
    "identificationDocs": {
        
    },
    "extra": {
        "pin": "12345678"
    },
    "webhook": {
        "url": "callback_url"
    }
}
```

- **rao.certificatePin** è pin del certificato del RAO utilizzato per emettere il certificato
- **identificationProcess** indica il processo di identificazione utilizzato. E' un campo opzionale poichè nel caso di profili con un singolo processo associato questa informazione è ininfluente
- **extra.pin** è pin che si vuole associare al certificato che si sta emettendo. Ammesso che il certificato necessiti di un pin.
- **webhook.url** è l'url del webhook che il servizio invocherà per comunicare l'esito dell'operazione. Infatti il servizio in questione è asincrono.
- **identificationDocs** è la sezione che contiene i documenti di identificazione del titolare. Esistono due modi per fornire i documenti e si rimanda alla sezione relativa

Il servizio, in quanto, asincrono, ritorna un **202** per segnalare la presa in carico dell'operazione.

Ad emissione completata, il servizio avrà cura di:

- inviare al titolare (e se SEAL anche alla mail di organization) una mail con le indicazioni relative al certificato emesso, con in allegato il pdf del modulo di richiesta opportunamente firmato sia dal titolare che dal RAO
- inviare un webhook all'integratore con i dati del certificato
- inviare tutti i documenti prodotti in conservazione

##### **Reg exp numero documento, in base al type**

- IDC: <span style="font-size: 12.0pt; mso-fareast-font-family: 'Times New Roman';">^(\[a-zA-Z\]{2}\[ \]?\[\\d\]{5}\[ \]?\[a-zA-Z\]{2}|\[a-zA-Z\]{2}\[ \]?\[\\d\]{7})$</span>
- <span style="font-size: 12.0pt; mso-fareast-font-family: 'Times New Roman';">PAS: ^\[a-zA-Z\]{2}\[\\d\]{7}$</span>
- DLC: <span style="font-size: 12.0pt; mso-fareast-font-family: 'Times New Roman';">^\[U\]1\[A-Za-z0-9\]{8}$ **OR** ^\[A-Z\]{2}\\d{7}\[A-Z\]$</span>

##### **Reg exp mail**

Data la mail [user@domain](mailto:user@domain)

- user: <span style="font-size: 12.0pt; font-family: 'Calibri',sans-serif; mso-fareast-font-family: 'Times New Roman'; color: black; mso-ansi-language: IT; mso-fareast-language: IT; mso-bidi-language: AR-SA;">(^\[-!#$%&amp;'*<span style="font-family: 'Calibri',sans-serif;">+/=?^\_</span>*</span>`<em><span style="font-size: 10.0pt; color: black; mso-ansi-language: IT; mso-fareast-language: IT; mso-bidi-language: AR-SA;">{}|~0-9A-Z]+(<a href="file://.[-!%23$%25&'*+/=%3f%5e_%7b%7d|~0-9A-Z%5d+)/Z|%5e%22(%5b/001-/010/013/014/016-/037!%23-/%5b/%5d-/177%5d|/%5b/001-/011/013/014/016-/177%5d)*%22/Z">\\.[-!#$%&'*+/=?^_<span style="font-size: 12.0pt; font-family: 'Calibri',sans-serif; mso-fareast-font-family: 'Times New Roman'; font-style: normal;">{}|~0-9A-Z]+)\Z|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"\Z</span></a></span></em>`<span style="font-size: 12.0pt; font-family: 'Calibri',sans-serif; mso-fareast-font-family: 'Times New Roman'; color: black; mso-ansi-language: IT; mso-fareast-language: IT; mso-bidi-language: AR-SA;">)</span>
- <span style="font-size: 12.0pt; font-family: 'Calibri',sans-serif; mso-fareast-font-family: 'Times New Roman'; color: black; mso-ansi-language: IT; mso-fareast-language: IT; mso-bidi-language: AR-SA;">domain: (?:A-Z0-9?\\.)+(?:\[A-Z\]{2,6}|\[A-Z0-9-\]{2,}(?&lt;!-))\\Z</span>

In risposta il servizio ritorna:

```JSON
{
  "requestId": "64a0895e8620872ba1be33e7",
  "document": "JVBERi0xLjYNJeLjz9MNCjQ5NiAwIG9iag0.......2SBV65FF6ic7HWtBZlDsR5T5FuYsFKZgHdlWwD/Rc8BLt/wGjScohDQplbmRzdHJlYW0KZW5kb2JqCnN0YXJ0eHJlZgoyNzg1NTMKJSVFT0YK"
}
```

<div id="bkmrk-dove%3A-requestid-%C3%A8-l%27-1"><div><div aria-hidden="false" aria-labelledby="Snc6mBA=" data-name="examplePanel">dove:</div>- **requestId** è l'id della richiesta appena aperta
- **document** è il pdf del modulo di richiesta opportunamente fillato in base 64. Tale modulo deve essere preso in visione dal titolare

</div></div>#### **Modalità di caricamento dei documenti di identificazione**

##### **In fase di chiamata di completamento**

La modalità più semplice è rappresentata dal passaggio dei documenti in fase di chiamata di completamento all'interno del campo **identificationDocs**:

**SPID**

```JSON
"identificationDocs": {
  "documents": [
    {
      "name": "evidences.json",
      "data": "JVBERi0xLjYNJeLjz9MNCjQ5NiAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAyNTA1NDQvTyA0OTgvRSAyMTAwNDkvTiAzL1QgMjUwMTE2L0ggWyA3NzEgNDQ5XT4+DWVuZG9iag0gICAgICAgICAgICAgDQo1NjIgMCBvYmoNPDwvRGVjb2RlUGFybXM8PC9Db2x1bW5zIDUvUHJlZGljdG9yIDEyPj4vRmlsdGVyL0ZsYXRlRGVjb2RlL0lEWzwxM0VEQkU4Rjg5NjQ5NjRBODYyNTcwOUIxMEQ1REJFRD48RkIxMTM4OUE0OTI1OEI0Mzg5QUYyNDYzRUY0QUUxRT...."
    },
    {
      "name" : "spid.request.xml",
      "data" : "JVBERi0xLjYNJeLjz9MNCjQ5NiAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAyNTA1NDQvTyA0OTgvRSAyMTAwNDkvTiAzL1QgMjUwMTE2L0ggWyA3NzEgNDQ5XT4+DWVuZG9iag0gICAgICAgICAgICAgDQo1NjIgMCBvYmoNPDwvRGVjb2RlUGFybXM8PC9Db2x1bW5zIDUvUHJlZGljdG9yIDEyPj4vRmlsdGVyL0ZsYXRlRGVjb2RlL0lEWzwxM0VEQkU4Rjg5NjQ5NjRBODYyNTcwOUIxMEQ1REJFRD48RkIxMTM4OUE0OTI1OEI0Mzg5QUYyNDYzRUY0QUUxRT...."
    },
    {
      "name" : "spid.response.xml",
      "data" : "JVBERi0xLjYNJeLjz9MNCjQ5NiAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAyNTA1NDQvTyA0OTgvRSAyMTAwNDkvTiAzL1QgMjUwMTE2L0ggWyA3NzEgNDQ5XT4+DWVuZG9iag0gICAgICAgICAgICAgDQo1NjIgMCBvYmoNPDwvRGVjb2RlUGFybXM8PC9Db2x1bW5zIDUvUHJlZGljdG9yIDEyPj4vRmlsdGVyL0ZsYXRlRGVjb2RlL0lEWzwxM0VEQkU4Rjg5NjQ5NjRBODYyNTcwOUIxMEQ1REJFRD48RkIxMTM4OUE0OTI1OEI0Mzg5QUYyNDYzRUY0QUUxRT...."
    }
  ]
}
```

**CIE**

```JSON
"identificationDocs": {
  "documents": [
    {
      "name": "evidences.json",
      "data": "JVBERi0xLjYNJeLjz9MNCjQ5NiAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAyNTA1NDQvTyA0OTgvRSAyMTAwNDkvTiAzL1QgMjUwMTE2L0ggWyA3NzEgNDQ5XT4+DWVuZG9iag0gICAgICAgICAgICAgDQo1NjIgMCBvYmoNPDwvRGVjb2RlUGFybXM8PC9Db2x1bW5zIDUvUHJlZGljdG9yIDEyPj4vRmlsdGVyL0ZsYXRlRGVjb2RlL0lEWzwxM0VEQkU4Rjg5NjQ5NjRBODYyNTcwOUIxMEQ1REJFRD48RkIxMTM4OUE0OTI1OEI0Mzg5QUYyNDYzRUY0QUUxRT...."
    },
    {
      "name" : "cie.request.xml",
      "data" : "JVBERi0xLjYNJeLjz9MNCjQ5NiAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAyNTA1NDQvTyA0OTgvRSAyMTAwNDkvTiAzL1QgMjUwMTE2L0ggWyA3NzEgNDQ5XT4+DWVuZG9iag0gICAgICAgICAgICAgDQo1NjIgMCBvYmoNPDwvRGVjb2RlUGFybXM8PC9Db2x1bW5zIDUvUHJlZGljdG9yIDEyPj4vRmlsdGVyL0ZsYXRlRGVjb2RlL0lEWzwxM0VEQkU4Rjg5NjQ5NjRBODYyNTcwOUIxMEQ1REJFRD48RkIxMTM4OUE0OTI1OEI0Mzg5QUYyNDYzRUY0QUUxRT...."
    },
    {
      "name" : "cie.response.xml",
      "data" : "JVBERi0xLjYNJeLjz9MNCjQ5NiAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAyNTA1NDQvTyA0OTgvRSAyMTAwNDkvTiAzL1QgMjUwMTE2L0ggWyA3NzEgNDQ5XT4+DWVuZG9iag0gICAgICAgICAgICAgDQo1NjIgMCBvYmoNPDwvRGVjb2RlUGFybXM8PC9Db2x1bW5zIDUvUHJlZGljdG9yIDEyPj4vRmlsdGVyL0ZsYXRlRGVjb2RlL0lEWzwxM0VEQkU4Rjg5NjQ5NjRBODYyNTcwOUIxMEQ1REJFRD48RkIxMTM4OUE0OTI1OEI0Mzg5QUYyNDYzRUY0QUUxRT...."
    }
  ]
}
```

**VIDEO**

```JSON
"identificationDocs": {
  "documents": [
    {
      "name": "evidences.json",
      "data": "JVBERi0xLjYNJeLjz9MNCjQ5NiAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAyNTA1NDQvTyA0OTgvRSAyMTAwNDkvTiAzL1QgMjUwMTE2L0ggWyA3NzEgNDQ5XT4+DWVuZG9iag0gICAgICAgICAgICAgDQo1NjIgMCBvYmoNPDwvRGVjb2RlUGFybXM8PC9Db2x1bW5zIDUvUHJlZGljdG9yIDEyPj4vRmlsdGVyL0ZsYXRlRGVjb2RlL0lEWzwxM0VEQkU4Rjg5NjQ5NjRBODYyNTcwOUIxMEQ1REJFRD48RkIxMTM4OUE0OTI1OEI0Mzg5QUYyNDYzRUY0QUUxRT...."
    }
  ]
}
```

**FEQ**

```JSON
"identificationDocs": {
  "documents": [
    {
      "name": "request_module.pdf",
      "data": "JVBERi0xLjYNJeLjz9MNCjQ5NiAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAyNTA1NDQvTyA0OTgvRSAyMTAwNDkvTiAzL1QgMjUwMTE2L0ggWyA3NzEgNDQ5XT4+DWVuZG9iag0gICAgICAgICAgICAgDQo1NjIgMCBvYmoNPDwvRGVjb2RlUGFybXM8PC9Db2x1bW5zIDUvUHJlZGljdG9yIDEyPj4vRmlsdGVyL0ZsYXRlRGVjb2RlL0lEWzwxM0VEQkU4Rjg5NjQ5NjRBODYyNTcwOUIxMEQ1REJFRD48RkIxMTM4OUE0OTI1OEI0Mzg5QUYyNDYzRUY0QUUxRT...."
    }
  ]
}
```

##### **Con chiamata separata**

Un'altra possibilità è rappresentata dal servizio di caricamento:

<p class="callout info">[Caricamento documenti](https://ca-test.agyo.io/openapi/swagger-ui/index.html?urls.primaryName=certificate-document#/document-upload-controller/upload "Caricamento documenti")</p>

Tale metodo ritorna in output una stringa **storageFolder** che indica il bucket dove i documenti sono stati caricati.

Quindi, in fase di chiamata di completamento, sarà sufficiente andare a fornire tale info all'interno di **identificationDocs**:

```JSON
"identificationDocs": {
  "storageFolder": "nome"
}
```

##### **Esempio di webhook finale con le informazioni di emissione**

```json
{
  "success": true,
  "traceId": "bc45872a9bb9c0c554b72b0c63a08686",
  "id": "651a7b31a1dbc2080aa58b67",
  "context": "CERTIFICATE_CREATION",
  "event": "EMITTED",
  "data": {
    "certificate": {
      "alias": "70724",
      "validFrom": "2023-10-02T08:11:00",
      "validTo": "2024-10-01T14:11:00",
      "profile": "AUTO",
      "signaturesNumber": 0
    },
    "owner": {
      "alias": "TINIT-FRMTTR76M06B715E",
      "firstName": "Ettore",
      "lastName": "Fieramosca",
      "birthDate": "1976-08-06",
      "birthDistrict": "CE",
      "birthCity": "Capua",
      "birthCountry": "IT",
      "sex": "M",
      "email": "a.mariano@teamsystem.com",
      "phoneNumber": "+393452495944"
    }
  }
}
```

I webhook emessi dal servizio saranno tutti caratterizzati dal context **CERTIFICATE\_CREATION.** Il valore del campo **EVENT** permetterà di distinguere la tipologia di evento.

**EMITTED** per esempio sarà il valore del campo evento che segnalerà il completamento dell'emissione del certificato