//Full Onboarding

Tutorial: Full User Onboarding and Authentication

This tutorial will guide you through the complete process of creating an organization, registering the first user, and authenticating them.

1. Create an Organization

To create an organization, you will need to make a POST request to the /organizations endpoint.

Input: ~~~json { "name": "My Awesome Company" } ~~~

~~~bash curl -X POST https://api.buttrbase.com/v1/organizations -H 'Authorization: Bearer YOUR_API_KEY' -H 'Content-Type: application/json' -d '{ "name": "My Awesome Company" }' ~~~

Output: ~~~json { "org_uuid": "org-uuid-123", "name": "My Awesome Company" } ~~~

2. Register the First User

Now that you have an organization, you can register the first user.

Input: ~~~json { "org_uuid": "ORG_UUID", "email": "admin@company.com", "password": "secure_password" } ~~~

~~~bash curl -X POST https://api.buttrbase.com/v1/users -H 'Authorization: Bearer YOUR_API_KEY' -H 'Content-Type: application/json' -d '{ "org_uuid": "ORG_UUID", "email": "admin@company.com", "password": "secure_password" }' ~~~

Output: ~~~json { "user_uuid": "user-uuid-abc", "email": "admin@company.com" } ~~~

3. Log the User In

To log in, make a POST request to the /auth/login endpoint.

Input: ~~~json { "email": "admin@company.com", "password": "secure_password" } ~~~

~~~bash curl -X POST https://api.buttrbase.com/v1/auth/login -H 'Content-Type: application/json' -d '{ "email": "admin@company.com", "password": "secure_password" }' ~~~

Output: ~~~json { "token": "jwt_token...", "user": { "email": "admin@company.com" } } ~~~

4. Store the JWT

The JWT should be stored securely on the client-side (e.g., in localStorage or a secure cookie).