Using the Thrinacia REST API to authenticate, create an account and a simple campaign

This article will show how to use the Thrinacia REST API to authenticate, create an account and a simple campaign.
Once you have your REST API URL and credentials you will be able to make requests to the API and recieve responses in JSON.

Your base API URL will look something like https://example.com/api/service/restv1/.

First we will authenticate with the admin credentials provided to you. Example credentials are provided below.

email: admin@example.com
password: examplepassword

You will make a POST  request to the endpoint “authenticate”. For our example it will look like “https://example.com/api/service/restv1/authenticate” with email and password parameter.

{
  "bio": null,
  "first_name": "Portal Admin",
  "disabled": 0,
  "person_id": "1",
  "email": "myadmin@thrinacia.com",
  "person_type_id": 1,
  "created": "2024-02-13 12:49:53.397524-08",
  "attributes": "{}",
  "id": "1",
  "last_name": "User",
  "campaign_manager": 1,
  "campaign_backer": 1,
  "portal_admin": 1,
  "person_status_id": 2,
  "modified": "2024-05-15 15:49:16.656984-07",
  "auth_token": "4d050dc78d0ee1896adff5471f353691aae497f0"
}

After authenticating you can use the auth_token from the admin account to make requests to admin endpoints. The admin can create users by making a POST request to the “portal/person” endpoint. Your posted data will look something like this.

{
  "first_name": "test",
  "last_name": "test",
  "email": "test@example.com",
  "person_status_id": "2",
  "password": "testing",
  "password_confirm": "testing",
  "person_type_id": "2",
  "attributes": "{}"
}

Further info for ids, person_status_id is for the status of the user and person_type_id is the type of the user account.
1 is Pending, 2 is Approved , 3 is Disabled are other person_status_ids.
1 is Portal Administrator, 2 is Regular User, 3 is Campaign Administrator, 4 is Page Administrator are other person_type_ids.
You will then receive a response that looks like this.

{
  "id": "5",
  "inline_token": null,
  "person_id": "5",
  "token": "AD7674D8-34E9-11EF-9B8C-1F6FD750383D-353148751211410873971829435196704743243"
}

You will now be able to authenticate as this new user. Regular users don’t have access to endpoints like POST requests to “portal/person” to create users. If you attempt to use endpoints you don’t have access to, you will get this response.

{
  "message": "Not a portal admin, unable to view specified resource",
  "code": "account_permission_not_portal_admin"
}

As a regular user you can create a basic campaign with a POST request to the “campaign” endpoint with some basic data.

{
  "name":"Example Campaign",
  "raise_mode_id":2,
  "profile_type_id":2,
  "duration_type_id":1,
  "category_id":1,
  "blurb":"Example Blurb",
  "description":"Example Description",
  "funding_goal":1000,
  "starts":2024-06-28T16:30:00,
  "ends":2025-06-28T16:30:00,
  "runtime_days":365
}

The required parameters here are name, raise_mode_id and profile_type_id.

raise_mode_id: 1 is All or Nothing Funding Mode, 2 is Keep it All Funding Mode

profile_type_id: 1 is Individual User Profile, 2 is Business Organization Profile

duration_type: 1 is Time Based Campaign, 2 is Continuous Campaign

category_id: There are a few default categories, you can also add your own.

– 1 Art
– 2 Business
– 3 Design
– 4 Education
– 5 Fashion
– 6 Film & Video
– 7 Food
– 8 Gaming
– 9 Health
– 10 Journalism
– 11 Music
– 12 Photography
– 13 Publishing
– 14 Sports
– 15 Technology

Leave a comment

Your email address will not be published. Required fields are marked *