Enviar factura via SDI
Recepta ràpida per emetre una factura a l’SDI (Sistema di Interscambio) amb l’API de B2Brouter: compte → contacte → factura → estat.
1. Crear el compte de l’empresa italiana
Section titled “1. Crear el compte de l’empresa italiana”curl --request POST \ --url https://api-staging.b2brouter.net/accounts \ --header 'X-B2B-API-Key: {YOUR_API_KEY}' \ --header 'X-B2B-API-Version: {YOUR_API_VERSION}' \ --header 'content-type: application/json' \ --data '{ "account": { "country": "it", "tin_value": "20339260422", "tin_scheme": 211, "name": "Test Sender Italy", "address": "Milano street, 1", "city": "Milano", "postalcode": "20019", "province": "MI", "tax_regime": "RF01" } }'2. Crear el contacte de client
Section titled “2. Crear el contacte de client”transport_type_code: it.sdi, document_type_code: xml.fatturapa.1.2, la Partita IVA amb tin_scheme: 9906 (o el Codice Fiscale amb cin_scheme: 9907), i el Codice Destinatario a recipient_code (si no en té, 0000000).
curl --request POST \ --url https://api-staging.b2brouter.net/accounts/{ACCOUNT_ID}/contacts \ --header 'X-B2B-API-Key: {YOUR_API_KEY}' \ --header 'X-B2B-API-Version: {YOUR_API_VERSION}' \ --header 'content-type: application/json' \ --data '{ "contact": { "tin_scheme": "9906", "tin_value": "IT12345678901", "name": "Esempio S.r.l.", "address": "Via Inventata 88", "postalcode": "00184", "city": "Roma", "province": "RM", "country": "it", "transport_type_code": "it.sdi", "document_type_code": "xml.fatturapa.1.2", "recipient_code": "{CODICE_DESTINATARIO}" } }'3. Crear i enviar la factura
Section titled “3. Crear i enviar la factura”Amb send_after_import: true la factura s’envia directament a l’SDI.
curl --request POST \ --url https://api-staging.b2brouter.net/accounts/{ACCOUNT_ID}/invoices \ --header 'X-B2B-API-Key: {YOUR_API_KEY}' \ --header 'X-B2B-API-Version: {YOUR_API_VERSION}' \ --header 'content-type: application/json' \ --data '{ "send_after_import": true, "invoice": { "type": "IssuedInvoice", "number": "1", "date": "2025-01-22", "contact_id": {YOUR_CONTACT_ID}, "invoice_lines_attributes": [ { "quantity": 10, "price": 47, "description": "Test Item", "taxes_attributes": [{ "name": "IVA", "percent": 22 }] } ] } }'4. Comprovar l’estat
Section titled “4. Comprovar l’estat”curl --request GET \ --url 'https://api-staging.b2brouter.net/invoices/{INVOICE_ID}' \ --header 'X-B2B-API-Key: {YOUR_API_KEY}' \ --header 'X-B2B-API-Version: {YOUR_API_VERSION}' \ --header 'accept: application/json'La factura passa per sending → sent; si l’SDI la rebutja, passa a error. Vegeu Comprovar l’estat de la factura per als detalls i el pas d’acknowledge.