API > Representation document - Upload document

Representation document - Upload document

POST  https://{entorno}.ticketbaiws.eus/doc-representante/

Uploads the digitally signed representation document (authorization to act on the company's behalf) for Verifactu, Bizkaia or Gipuzkoa. For individuals, it is signed by the holder; for legal entities, by the legal representative given when downloading the template. A recognized digital certificate (FNMT, Izenpe…) must be used. The NIF (Spanish tax ID) of the signature is checked against that of the company or the representative.

The request is sent as multipart/form-data, not as JSON.

Companies in Araba: this method is not available, because in Araba the authorization is given by registering the device certificate (see instructions). It returns an error:

{"result": "ERROR", "return": null, "msg": "El documento de representación no está disponible para empresas de Araba. Registra el certificado de dispositivo de Ticketbai WS en la sede de la Diputación Foral de Álava."}

PARAMETERS

file file required
PDF of the digitally signed representation document, sent as a multipart/form-data field.
documento.pdf


POST https://api.ticketbaiws.eus/doc-representante/
$ curl --request POST \
     --url https://api.ticketbaiws.eus/doc-representante/ \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --header 'Token: xxx' \
     --header 'Nif: 00000014Z'
	 --form 'file=@"/ruta/documento-firmado.pdf"'
$ composer require ticketbaiws/ticketbaiws-php
<?php
// Installation: composer require ticketbaiws/ticketbaiws-php
require 'vendor/autoload.php';

$tbai = new \TicketbaiWS\Client('xxx', '00000014Z', ['entorno' => 'real']);

$r = $tbai->enviarDocRepresentante('/ruta/documento-firmado.pdf');

if ($r->isError()) {
    echo $r->getMessageText();
} else {
    print_r($r->getData());
}
$ python -m pip install requests
import requests

url = "https://api.ticketbaiws.eus/doc-representante/"

headers = {"Accept": "application/json", "Token" : "xxx", "Nif" : "00000014Z"}

files = {
    "file": ("document-firmado.pdf", open("/ruta/documento-firmado.pdf", "rb"), "application/pdf")
}

response = requests.post(url, headers=headers, files=files)

print(response.text)
CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.ticketbaiws.eus/doc-representante/");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

// -------------------------
//    FORMULARIO MULTIPART
// -------------------------

curl_mime *mime;
curl_mimepart *part;

mime = curl_mime_init(hnd);

// Campo "filename"
part = curl_mime_addpart(mime);
curl_mime_name(part, "filename");
curl_mime_data(part, "documento-firmado.pdf", CURL_ZERO_TERMINATED);

// Campo "file" → fichero real
part = curl_mime_addpart(mime);
curl_mime_name(part, "file");
curl_mime_filedata(part, "/ruta/documento-firmado.pdf");

// Asignar formulario al handle
curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime);

CURLcode ret = curl_easy_perform(hnd);
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");

// Archivo a enviar
File file = new File("/ruta/documento-firmado.pdf");

// Construimos el body multipart
RequestBody requestBody = new MultipartBody.Builder()
    .setType(MultipartBody.FORM)
    // Campo "file"
    .addFormDataPart(
            "file",                   // nombre del campo
            file.getName(),           // nombre del archivo
            RequestBody.create(file, MediaType.parse("application/pdf"))
    )
    // You can add more fields if the endpoint requires them
    .addFormDataPart("filename", file.getName())
    .build();

Request request = new Request.Builder()
  .url("https://api.ticketbaiws.eus/doc-representante/")
  .post(RequestBody)
  .addHeader("Accept", "application/json")
  .addHeader("Token", "xxx")
  .addHeader("Nif", "00000014Z")
  .build();
  
Response response = client.newCall(request).execute();
{ } Response JSON
HTTP/1.1 200 OK
{ 
	"result": "OK", 
	"return": "Documento procesado correctamente", 
	"msg": null 
}

TicketBAI / Verifactu methods

Representation document

BATUZ BIZKAIA specific methods

SII (AEAT)

Customers and products (invoicing tool)

Other methods