API > New company
New company
POST https://api.ticketbaiws.eus/empresas/
This method creates a new company record for sending TicketBAI invoices
PARAMETERS
| id_licencia integer optional ID of the license to link the company to. If omitted, the first free license is used or a new one is created | 999 |
| nombre_social string required Company's registered (legal) name | Empresa de ejemplo S.L. |
| nombre_comercial string optional Company's trade name | Neumáticos Pepe |
| nif string required Company's NIF (Spanish tax ID) | B01000012 |
| direccion string required Company's registered address | Calle de ejemplo 123 |
| poblacion string required Company's registered town/city | Vitoria-Gasteiz |
| provincia string required Company's registered province | Álava |
| cp string required Company's registered postal code | 01001 |
| email string optional Company's contact email | info@ejemplo.com |
| web string optional Company's website address | www.ejemplo.com |
diputacion integer required | 1 |
| epigrafe string required in Bizkaia only for self-employed individuals, CBs (comunidades de bienes) and SCs (sociedades civiles) IAE activity code | 301800 |
| spfe boolean optional Submission to the SPFE (Spanish public B2B e-invoicing platform) of the AEAT (Spanish Tax Agency), for B2B electronic invoicing under the Ley Crea y Crece. true enables it from that day on: full invoices issued to Spanish customers with a NIF are sent, and received invoices are downloaded. See SPFE methods | true |
| sii boolean optional Submission of the issued invoices book to the SII (Immediate Supply of Information) of the AEAT (Spanish Tax Agency), for companies in the common VAT territory (their invoices are no longer sent to Verifactu). true enables it from that day on: each invoice is recorded within 4 working days (in the Basque Country and Navarre, once the regional tax authority accepts it). See GET sii-envios | true |
POST https://api.ticketbaiws.eus/empresas/
$ curl --request POST \
--url https://api.ticketbaiws.eus/empresas/ \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Token: xxx' \
--header 'Nif: 00000014Z'
--data '
{
"id_licencia": "0",
"nombre_social": "Empresa de ejemplo S.L.",
"nombre_comercial": "Neumáticos Pepe",
"nif": "B01000012",
"direccion": "Calle de ejemplo 123",
"poblacion": "Vitoria-Gasteiz",
"provincia": "Álava",
"cp": "28080",
"email": "info@ejemplo.com",
"web": "www.ejemplo.com",
"diputacion": 1,
"epigrafe" : "301800"
}'
$ composer require ticketbaiws/ticketbaiws-php
<?php
// Installation: composer require ticketbaiws/ticketbaiws-php
require 'vendor/autoload.php';
$cuenta = new \TicketbaiWS\Cuenta('xxx', '00000014Z'); // token de desarrollador y NIF de la cuenta
$r = $cuenta->crearEmpresa([
'id_licencia' => '0',
'nombre_social' => 'Empresa de ejemplo S.L.',
'nombre_comercial' => 'Neumáticos Pepe',
'nif' => 'B01000012',
'direccion' => 'Calle de ejemplo 123',
'poblacion' => 'Vitoria-Gasteiz',
'provincia' => 'Álava',
'cp' => '28080',
'email' => 'info@ejemplo.com',
'web' => 'www.ejemplo.com',
'diputacion' => 1,
]);
if ($r->isError()) {
echo $r->getMessageText();
} else {
print_r($r->getData()); // incluye los tokens de test y real de la empresa
}
$ python -m pip install requests
import requests
url = "https://api.ticketbaiws.eus/empresas/"
payload = {
"id_licencia": "0",
"nombre_social": "Empresa de ejemplo S.L.",
"nombre_comercial": "Neumáticos Pepe",
"nif": "B01000012",
"direccion": "Calle de ejemplo 123",
"poblacion": "Vitoria-Gasteiz",
"provincia": "Álava",
"cp": "28080",
"email": "info@ejemplo.com",
"web": "www.ejemplo.com",
"diputacion": 1
}
headers = {"Accept": "application/json", "Token" : "xxx", "Nif" : "00000014Z"}
response = requests.request("POST", url, json=payload, headers=headers)
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/empresas/");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, '{"id_licencia":"0","nombre_social":"Empresa de ejemplo S.L.","nombre_comercial":"Neumáticos Pepe","nif":"B01000012","direccion":"Calle de ejemplo 123","poblacion":"Vitoria-Gasteiz","provincia":"Álava","cp":"28080","email":"info@ejemplo.com","web":"www.ejemplo.com","diputacion":1}');
CURLcode ret = curl_easy_perform(hnd);
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{"id_licencia":"0","nombre_social":"Empresa de ejemplo S.L.","nombre_comercial":"Neumáticos Pepe","nif":"B01000012","direccion":"Calle de ejemplo 123","poblacion":"Vitoria-Gasteiz","provincia":"Álava","cp":"28080","email":"info@ejemplo.com","web":"www.ejemplo.com","diputacion":1}');
Request request = new Request.Builder()
.url("https://api.ticketbaiws.eus/empresas/")
.post(body)
.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": {
"id": "999"
"id_licencia": "999",
"epigrafe": "",
"nombre_social": "Empresa de ejemplo S.L.",
"nombre_comercial": "Neumáticos Pepe",
"nif": "B01000012",
"direccion": "Calle de ejemplo 123",
"poblacion": "Vitoria-Gasteiz",
"provincia": "Álava",
"cp": "28080",
"email": "info@ejemplo.com",
"web": "www.ejemplo.com",
"diputacion": 1,
"token": "xxx",
"token_test": "xxx"
},
"msg": null
}
