Create Tenant
const url = 'https://sender.api.kivra.com/v2/tenant';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"Kivra","company_id":[{"name":"Kivra AB","orgnr":"SE556840226601"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://sender.api.kivra.com/v2/tenant \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "Kivra", "company_id": [ { "name": "Kivra AB", "orgnr": "SE556840226601" } ] }'Creation of tenants via API allows clients to create new tenants in an efficient manner. The created tenant is automatically added to the client scope. The client needs to re-authenticate to have the new scope in effect.
Note: Creation of tenants via API is only allowed in certain specific cases and its usage needs to be regulated in the business relationship between the sender party and Kivra.
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
Name of the Tenant, this name shows up in the Users Inbox
Example
Kivraobject
Legal name of Company
Example
Kivra ABVat number of Company
Example
SE556840226601Security level needed for an enduser to opt_out from this Tenant
Example
50List of groups this Tenant belongs to
Example
[]Determines if this Tenant is visible for the enduser
Datum when the tenant was created in UTC format
Example
2019-05-20T12:42:29ZID of client that created the tenant
Example
client_15063298495eafd2749bb78e2f991af3ab023d13dfInternal field describing whether the user can opt-out the tenant
Example
optionalInternal field
Example
opt_outResponses
Section titled “Responses”Tenant already existing and added to the client scope
object
Name of the Tenant, this name shows up in the Users Inbox
object
Legal name of Company
Vat number of Company
Security level needed for an enduser to opt_out from this Tenant
List of groups this Tenant belongs to
Determines if this Tenant is visible for the enduser
Datum when the tenant was created in UTC format
ID of client that created the tenant
Internal field describing whether the user can opt-out the tenant
Internal field
Example
{ "name": "Kivra", "company_id": [ { "name": "Kivra AB", "orgnr": "SE556840226601" } ], "edit_security_level": 25, "groups": [], "visibility": "visible", "created_at": "2019-05-20T12:42:29Z", "created_by": "client_15063298495eafd2749bb78e2f991af3ab023d13df", "status": "optional", "class": "opt_out"}Headers
Section titled “Headers”Tenant Key
URL to created Object
Tenant Created succesfully
object
Name of the Tenant, this name shows up in the Users Inbox
object
Legal name of Company
Vat number of Company
Security level needed for an enduser to opt_out from this Tenant
List of groups this Tenant belongs to
Determines if this Tenant is visible for the enduser
Datum when the tenant was created in UTC format
ID of client that created the tenant
Internal field describing whether the user can opt-out the tenant
Internal field
Example
{ "name": "Kivra", "company_id": [ { "name": "Kivra AB", "orgnr": "SE556840226601" } ], "edit_security_level": 25, "groups": [], "visibility": "visible", "created_at": "2019-05-20T12:42:29Z", "created_by": "client_15063298495eafd2749bb78e2f991af3ab023d13df", "status": "optional", "class": "opt_out"}Headers
Section titled “Headers”Tenant Key
URL to created Object
The tenant could not be created because of a conflict, meaning that a tenant with the same orgnr already exists and cannot be automatically added to the client scope. The client may use the request_access endpoint to request access to this tenant.
object
The 5-digits error code
A short message explaining the conflict
A text message explaining the conflict
Example
{ "code": 40915, "short_message": "Orgnumber already exist", "long_message": "One or more of the organisation numbers within the company_id's you provided, already exist in existing tenants. Tenants outside your scope: {Name: TestBolag, Tenant key: 1424780396902ee9278b16417f8e3252c3ced28c38, Organisation number: SE556840226601}"}