NAF affiliation
Registration of an affiliation number. This method is in beta.
Parameters
- dni (string) : Worker's identity document (DNI, NIE or passport).
- identificacion (integer) : Document type. Possible values (any other value returns
422witherrors.identificacion). If omitted, it is inferred from the document: DNI→1, NIE→6, anything else→2.- 1: DNI
- 2: Passport
- 6: NIE
- name (string) : First name.
- surname (string) : First surname.
- lastSurname (string) : Second surname, if any.
- country (integer) : Nationality. Possible values:
- sexo (string) : Sex. Possible values:
- M: Male
- F: Female
- fnacimiento (date) : Date of birth. Format YYYY-MM-DD.
- fatherName (string) : Father's name.
- motherName (string) : Mother's name.
- phoneCode (integer) : Dialling code. Example: 34
- phone (integer) : Phone number.
- streetType (string) : Street type: 2-letter uppercase code (
CL,AV…); otherwise422. Example:- CL: Street
- streetName (string) : Street name.
- streetNumber (string) : Street number.
- bis (string) : Bis.
- block (string) : Block.
- stairs (string) : Stairway.
- floor (string) : Floor.
- door (string) : Door.
- postalCode (string) : Postal code, maximum 5 digits.
- city (integer) : City. Possible values:
- 13044: Fuente el Fresno
- Table of municipality codes (opens in a new tab)
The address (streetType, streetName, postalCode, city…) must be the worker's, not the company's.
⚠️
TGSS limitation. Through the RED System you cannot assign a NAF to an EU/EEA/Swiss citizen identified with a passport or national ID and no NIE. Saltra detects it before calling the TGSS and answers 422 with errors.identificacion (see "Errors"). A NIE is required (EU citizen registration certificate, identificacion = 6). Without a NIE, the NAF must be requested at a TGSS office (form TA.1). A passport (2) does not work for these cases.
POST /assignment-nss
{
"dni": "12345678A",
"identificacion": 1,
"name": "Juan",
"surname": "Perez",
"lastSurname": "Garcia",
"country": 724,
"sexo": "M",
"fnacimiento": "2023-01-01",
"fatherName": "Juan",
"motherName": "Perez",
"phoneCode": 34,
"phone": 123456789,
"streetType": "CL",
"streetName": "Calle 1",
"streetNumber": "1",
"bis": "",
"block": "",
"stairs": "",
"floor": "4",
"door": "A",
"postalCode": "13044",
"city": 13044
}Response
Respuesta
{
"success": true,
"message": "OK",
"data": {
"nss": "123456789012",
"identity": "1",
"dni": "12345678A"
}
}Errors
422,identificacionnot 1, 2 or 6: "El campo Identificación debe ser 1 (DNI/NIF), 2 (Pasaporte) o 6 (NIE)."422,countryin the EU/EEA/Switzerland (excluding Spain) with effective type 2 (sent or inferred): Saltra does not call the TGSS.
Error 422
{
"success": false,
"status": 422,
"message": "validation_errors",
"data": [],
"errors": {
"identificacion": [
"La TGSS no asigna NAF por Sistema RED a ciudadanos de la UE/EEE sin NIE. Indica el NIE (certificado de registro de ciudadano de la UE, tipo 6) o solicita el NAF en una administración de la TGSS (modelo TA.1)."
]
}
}422: any other validation (errors.streetType…).502: rejection by the TGSS. If it answers3001and names a specific field, themessageends with the text "(campo rechazado por la TGSS: label — api_field)" anderrors.fieldholds the API key; if the field isidentificacion, the message adds the NIE hint. If the TGSS does not name the field, the message is the usual one and there is noerrors.field.
Error 502
{
"success": false,
"status": 502,
"message": "SISTEMA RED: 3001*ERROR DE VALIDACION U OBLIGATORIEDAD NO CUMPLIDA (campo rechazado por la TGSS: nombre del padre — `fatherName`)",
"data": [],
"errors": {
"tgss": [
"SISTEMA RED: 3001*ERROR DE VALIDACION U OBLIGATORIEDAD NO CUMPLIDA (campo rechazado por la TGSS: nombre del padre — `fatherName`)"
],
"field": [
"fatherName"
]
}
}