Scriberr uses session based authentication. To authenticate, make a POST
request to the token exchange endpoint:
Example:
const options = {
method: 'POST',
body: {
'email': "<user_email>",
'password': "<user_password>"
}
}
const res = await fetch('https://scriberr.co/api/sessions/auth', options);
const json = await res.json();
console.log(json)
/*
* {
* sessionToken: <user_session_token>,
* csrfToken: <user_csrf_token>,
* }
*/
Once the session token and CSRF token have been received, they must be included as __Secure-next-auth.session-token
and __Host-next-auth.csrf-token
cookies in all subsequent authenticated requests:
'Cookie': `__Secure-next-auth.session-token=${"<user_session_token>"}; __Host-next-auth.csrf-token=${"<user_csrf_token>"};`
Note: sessions are invalidated after 30 days, if your session is invalid, 401
unauthorized will be returned and you will need to re-authenticate for the latest session.
Path: https://scriberr.co/api/me
Method: GET
Description: Returns the authenticated user
Example Response Payload:
{
"created_at": "2020-10-30T17:56:53.471Z",
"email": "john.doe@gmail.com",
"id": 1,
"ref_id": "3bcb8ad0-e314-48eb-b441-f57a032e5c5f",
"removed_at": null,
"stripe_customer_id": "cus_id",
"stripe_subscription_id": "sub_id",
"updated_at": "2020-10-30T17:56:53.471Z"
}
________________________________________________________________
Path: https://scriberr.co/api/webhooks
Method: POST
Description: Subscribes the passed webhook URL to a Scriberr topic for the authenticated user. When a profile is copied using the Scriberr chrome extension, a POST request will be made with the person data as a JSON body to this endpoint.
Example Body Payload:
{
"hookUrl": "https://example.com/api/webhook/subscription/path",
"topic": "copy_data",
"name": "cool webhook"
}
________________________________________________________________
Path: https://scriberr.co/api/webhooks
Method: DELETE
Description: Deletes a webhook subscription given a webhook url and topic
Example Body Payload:
{
"hookUrl": "https://example.com/api/webhook/subscription/path",
"topic": "copy_data",
"name": "Custom Webhook"
}
________________________________________________________________
Path: https://scriberr.co/api/webhooks
Method: GET
Description: Fetches a list of webhooks currently enabled for the user
Example Response Payload:
{
"hooks": [{
"title": "Custom Webhook",
"hook_url": "https://example.com",
"topic": "copy_data"
}]
}