It creates TicketBAI invoices with the entered data. XML messages will be generated from these invoices, which are electronically signed and delivered to the corresponding tax administration.

1 POST Method - TicketBAI Invoice Registration

By making a POST request to the following API: https://mydeister.com/service/rest/{database}/tbai/v1/api/register TBAI documents are created from a JSON string, which allow XML messages to be generated and signed.

1.1 Parameters

The only required parameter is a chain in JSON format, which includes the fields belonging to:

  • Invoice heading and data: invoice identification (number, serial, date...), invoice details and breakdown.
  • Invoice subjects: information about the emisor and the destinatary.
  • Invoice Line data: the invoice lines are passed as a set, together with the rest of the invoice fields.

The tracing and signature data is produced afterwards, when the signed XML message is created, so these fields are not entered manually.

https://mydeister.com/service/rest/{database}/tbai/v1/api/register

Creation of a TBAI invoice with its correponding XML signed file, and chaining it to the last sent invoice.

Parameters:

  • json_data: JSON string

    Fields of the to-be-created invoice, including its lines.

Result:

If the execution is correct, the following values will be returned:

  • value: string

    Message with the value "OK".

  • id_tbai: string

    TBAI invoice identification.

  • qr_str: string

    Character string from which the QR code is generated.

  • firma: string

    Signature value of the signed XML message.

Nonetheless, if the execution turns out to be incorrect, the API will return the ocurred error.

1.2 Invoice fields

Field Format Required Description
emis_nif varchar(24) Issuer identification
emis_nombre varchar(60) Issuer name
emis_typ char(2) Issuer ID type (02 = national ID, 03 = passport)
emis_pais char(2) Issuer country
emis_zona char(6) Issuer fiscal zone
dest_nif char(20) Counterpart ID
dest_nombre varchar(60) Counterpart name
dest_type char(2) Counterpart ID type (02 = national ID, 03 = passport)
dest_pais char(2) Counterpart country
dest_zona char(6) Counterpart fiscal zone
dest_codpos varchar(20) Counterpart postal code
dest_direcc varchar(250) Counterpart address
dest_varios char(1) Various counterparts
dest_expter char(1) Issued by third parties
nifrepresenta char(9) ILOC Nif presentador
niftitular char(9) ILOC Nif titular
empcode char(4) ILOC Company
agetrib char(2) Tax agency
libro char(2) Record book (FE= Issued FE= Received)
ejercicio integer Fiscal exercise (year issued)
periodo char(2) Fiscal period (month issued)
seriefactura varchar(20) Series
numfactura varchar(20) Number
fechafactura date Date
horafactura datetime (hour to second) Hour minute second
simplificada char(1) Simplified or complete
sustitutiva char(1) Substitute for simplified
rectificacion char(2) Rectification, Code R1 to R5
tiporectif char(1) S or I Substitution or difference
baserec decimal(12,2) Rectified invoice base
cuotarec decimal(12,2) Rectified invoice fee
recarrec decimal(12,2) Rectified invoice surcharge
serrec varchar(20) Rectified invoice series
docrec varchar(60) Rectified invoice number
fecrec date Rectified invoice date
fecope date Date of the operation (only if different from the date of issue)
descoperacion varchar(250) Operations overview
importetotal decimal(12,2) Total invoice amount
retencion decimal(12,2) Supported retention
basecoste decimal(12,2) Tax base at cost
claveoperacion char(2) Operation key of special regime or of tax transcendence
claveoperaciona1 char(2) Additional Operation Key 1
claveoperaciona2 char(2) Additional Operation key 2
desglose char(1) Breakdown of tax details F=Invoice O=Operation
taiter smallint Common Tax area
numseriedisp char(30) Origin device identifier

1.3 Line fields

Field Format Required Description
line_type char(1) N = normal, R = retention, E = Equivalence surcharge
line_nature char(1) Classification B Goods/S Services
line_nosujeta char(2) Reason to be non subject RL Local Restrictions / OT other reasons
line_exenta char(2) Cause of exemption (null or from E1 to E6)
line_isp char(2) Reverse charge on VAT S1 No / S2 Yes
line_detalle varchar(250) Detailed description of the invoice line
line_cantidad decimal(12,2) Invoice line quantity
line_uniprecio decimal(12,8) Unit amount without VAT of the line
line_descuento decimal(12,2)n Discount invoice line
line_basimp decimal(14,2) Taxable base
line_basimp_noex decimal(14,2) Taxable base, not exempt
line_imp_porcen decimal(6,3) Applicable tax percentage
line_imp_cuoded decimal(14,2) Tax deductible fee
line_imp_cuonded decimal(14,2) Non-deductible fee for tax
line_equi_porcen decimal(6,3) Applicable percentage equivalence surcharge
line_equi_cuoded decimal(14,2) Deductible fee equivalence surcharge
line_importe decimal(14,2) Net amount with VAT of the invoice line

2 Examples

Example

API call from the console command lines.

Copy
curl -u username:password -X POST  -H "Accept: */*" -L "https://www.mydeister.com/service/rest/junit_icon/tbai/v1/api/register" -F json_data='{
        "nifrepresenta"     : "B62928809",
        "niftitular"        : "B62928809",
        "empcode"           : "GUI",
        "agetrib"           : "03",
        "libro"             : "FE",
        "descoperacion"     : "Varios",
        "ejercicio"         : 2021,
        "periodo"           : "07",
        "emis_nif"          : "B62928809",
        "emis_nombre"       : "Triathlon [GUI] S.L.",
        "emis_type"         : "02",
        "emis_pais"         : "ES",
        "emis_zona"         : "ESGU",
        "dest_nif"          : "B03930393",
        "dest_nombre"       : "ALBIR SPORT",
        "dest_type"         : "02",
        "dest_pais"         : "ES",
        "dest_zona"         : "ESCO",
        "dest_codpos"       : "03581",
        "dest_direcc"       : "Avenida del Albir 34",
        "dest_varios"       : "N",
        "dest_expter"       : "N",
        "numfactura"        : "FVNGUI21-000002",
        "fechafactura"      :  "19-07-2021",
        "horafactura"       : "02:00:00",
        "sustitutiva"       : "N",
        "fecope"            : "19-07-2021",
        "importetotal"      : 1210,
        "claveoperacion"    : "01",
        "desglose"          : "O",
        "taiter"            : 1,
        "tipocomunicacion"  : "A0",
        "erp_estado"        : "P",
        "lines"             :   [{
            "line_type"         : "N",
            "line_nature"       : "B",
            "line_isp"          : 0,
            "line_detalle"      : "Varios",
            "line_cantidad"     : 1,
            "line_uniprecio"    : 1000,
            "line_descuento"    : 0,
            "line_basimp"       : 1000,
            "line_basimp_noex"  : 0,
            "line_imp_porcen"   : 21,
            "line_imp_cuoded"   : 210,
            "line_imp_cuonded"  : 0,
            "line_equi_porcen"  : 0,
            "line_equi_cuoded"  : 0,
            "line_importe"      : 1000
        },
        {
            "line_type"         : "N",
            "line_nature"       : "B",
            "line_isp"          : 0,
            "line_detalle"      : " ",
            "line_cantidad"     : 1,
            "line_uniprecio"    : 1000,
            "line_descuento"    : 0,
            "line_basimp"       : 1000,
            "line_basimp_noex"  : 0,
            "line_imp_porcen"   : 10,
            "line_imp_cuoded"   : 100,
            "line_imp_cuonded"  : 0,
            "line_equi_porcen"  : 0,
            "line_equi_cuoded"  : 0,
            "line_importe"      : 1000
        }]
    }'
Example

JavaScript API call.

Copy
var json_data = {
            "nifrepresenta"     : "B62928809",
            "niftitular"        : "B62928809",
            "empcode"           : "GUI",
            "agetrib"           : "03",
            "libro"             : "FE",
            "descoperacion"     : "Varios",
            "ejercicio"         : 2021,
            "periodo"           : "07",
            "emis_nif"          : "B62928809",
            "emis_nombre"       : "Triathlon [GUI] S.L.",
            "emis_type"         : "02",
            "emis_pais"         : "ES",
            "emis_zona"         : "ESGU",
            "dest_nif"          : "B03930393",
            "dest_nombre"       : "ALBIR SPORT",
            "dest_type"         : "02",
            "dest_pais"         : "ES",
            "dest_zona"         : "ESCO",
            "dest_codpos"       : "03581",
            "dest_direcc"       : "Avenida del Albir 34",
            "dest_varios"       : "N",
            "dest_expter"       : "N",
            "numfactura"        : "FVNGUI21-000002",
            "fechafactura"      :  "19-07-2021",
            "horafactura"       : "02:00:00",
            "sustitutiva"       : "N",
            "fecope"            : "19-07-2021",
            "importetotal"      : 1210,
            "claveoperacion"    : "01",
            "desglose"          : "O",
            "taiter"            : 1,
            "tipocomunicacion"  : "A0",
            "erp_estado"        : "P",
            "lines"             :   [{
                "line_type"         : "N",
                "line_nature"       : "B",
                "line_isp"          : 0,
                "line_detalle"      : "Varios",
                "line_cantidad"     : 1,
                "line_uniprecio"    : 1000,
                "line_descuento"    : 0,
                "line_basimp"       : 1000,
                "line_basimp_noex"  : 0,
                "line_imp_porcen"   : 21,
                "line_imp_cuoded"   : 210,
                "line_imp_cuonded"  : 0,
                "line_equi_porcen"  : 0,
                "line_equi_cuoded"  : 0,
                "line_importe"      : 1000
            },
            {
                "line_type"         : "N",
                "line_nature"       : "B",
                "line_isp"          : 0,
                "line_detalle"      : " ",
                "line_cantidad"     : 1,
                "line_uniprecio"    : 1000,
                "line_descuento"    : 0,
                "line_basimp"       : 1000,
                "line_basimp_noex"  : 0,
                "line_imp_porcen"   : 10,
                "line_imp_cuoded"   : 100,
                "line_imp_cuonded"  : 0,
                "line_equi_porcen"  : 0,
                "line_equi_cuoded"  : 0,
                "line_importe"      : 1000
            }]
        }'
                    
let str = JSON.stringify(json_data)

let url = 'tbai/v1/api/register';

let result = new Ax.net.HttpClient()
    .setBasicAuthorization('username','password')
    .post("https://mydeister.com/service/rest/junit_icon/" + url)
    .header("Content-Type", "application/json")
    .body(str)
    .ensureSuccess()
    .asJsonObject()
    .getBody()
    .toMap();

return result;