Request access to a tenant
const url = 'https://sender.api.kivra.com/v2/tenant/request_access';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"vat_number":"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/request_access \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "vat_number": "SE556840226601" }'Request access to an existing tenant that is outside the client scope. Typically this request follows an unsuccessful attempt to create a tenant that resulted in a conflict error (error 409).
The meaning of the conflict error is that a tenant is already associated to a company_id including the same orgnr as in the tenant that the client attempted to post, and the tenant who owns the orgnr is outside the scope for the client.
In Kivra, it is allowed to have several different flows on the same tenant, for example one flow for invoices and another flow for salary slips. As these flows could be managed by different clients, we need a mechanism to allow sharing a tenant between clients.
The request_access endpoint provide this functionality. As the request may be granted (or denied) asynchronously, after a successfull call to request_access the client will need to poll the request until it becomes accepted or rejected.
As allowing access to a new tenant requires modification of the scope for the client, an authorization must be performed once the request has been accepted, to retrieve an access token with the new scope.
If the client posts a new identical request (requesting the same OrgNr for the same client), the same object will be returned with an updated status.
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
Example
SE556840226601Responses
Section titled “Responses”Data about the requested tenant
object
Datum when the request was created in UTC format
ID of client that created the request
Status of the request, for instance pending, accepted or rejected
ID Of You the Client
Name of the client who created the requested tenant
Name of the requested tenant
Key of the requested tenant
Example
{ "created_at": "2019-05-20T12:42:29Z", "created_by": "client_15063298495eafd2749bb78e2f991af3ab023d13df", "status": "pending", "client_name": "Client XYZ", "tenant_name": "Tenant ABC", "tenant_key": "1424780396902ee9278b16417f8e3252c3ced28c38"}Headers
Section titled “Headers”Object Key for the Request (requestKey)
The complete API url for where to check the status of this request