> For the complete documentation index, see [llms.txt](https://openup.gitbook.io/cape-agulhas-app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openup.gitbook.io/cape-agulhas-app/api/accounts.md).

# Accounts

## Register new user

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/accounts/register/`

Register new user

#### Request Body

| Name              | Type   | Description                          |
| ----------------- | ------ | ------------------------------------ |
| password\_confirm | string | Password confirm                     |
| password          | string | User password                        |
| username          | string | User name (can be the same as email) |
| email             | string | User email                           |

{% tabs %}
{% tab title="201 New user created" %}

```
{}
```

{% endtab %}

{% tab title="400 Validation errors" %}

```
{"field_name": "Error description"}
```

{% endtab %}
{% endtabs %}

## Verify registration

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/accounts/verify-registration/`

Verify user email from the verification link

#### Request Body

| Name      | Type    | Description                 |
| --------- | ------- | --------------------------- |
| user\_id  | string  | Django model user ID        |
| signature | string  | HMAC verification signature |
| timestamp | integer | User registration timestamp |

{% tabs %}
{% tab title="200 User account verified" %}

```
{}
```

{% endtab %}
{% endtabs %}

## Retrieve reset password link

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/accounts/send-reset-password-link/`

Send reset password link to the user by email

#### Request Body

| Name  | Type   | Description |
| ----- | ------ | ----------- |
| email | string | User email  |

{% tabs %}
{% tab title="200 Reset password link was sent" %}

```
{}
```

{% endtab %}

{% tab title="404 User not found" %}

```
{}
```

{% endtab %}
{% endtabs %}

## Set new user password

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/accounts/reset-password/`

Set new user password from the reset link

#### Request Body

| Name      | Type    | Description                      |
| --------- | ------- | -------------------------------- |
| password  | string  | New user password                |
| signature | string  | HMAC verification signature      |
| timestamp | integer | Reset password request timestamp |
| user\_id  | string  | Django model user ID             |

{% tabs %}
{% tab title="200 " %}

```
{}
```

{% endtab %}

{% tab title="400 " %}

```
{"field_name": "Error description"}
```

{% endtab %}
{% endtabs %}

## Login user

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/account/login/`

Login user with username and password

#### Request Body

| Name     | Type   | Description   |
| -------- | ------ | ------------- |
| password | string | User password |
| login    | string | User name     |

{% tabs %}
{% tab title="200 " %}

```
{"token": "JWT.TOKEN"}
```

{% endtab %}

{% tab title="400 Username or password are invalid" %}

```
```

{% endtab %}
{% endtabs %}

## Logout user

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/accounts/logout/`

Logout user from the system

#### Path Parameters

| Name          | Type    | Description          |
| ------------- | ------- | -------------------- |
| revoke\_token | boolean | Revoke current token |

#### Headers

| Name                | Type   | Description      |
| ------------------- | ------ | ---------------- |
| HTTP\_AUTHORIZATION | string | Bearer JWT.TOKEN |

{% tabs %}
{% tab title="200 " %}

```
{}
```

{% endtab %}
{% endtabs %}

## Get user profile info

<mark style="color:blue;">`GET`</mark> `https://muni-portal-backend.openup.org.za/api/accounts/profile/`

#### Headers

| Name                | Type   | Description      |
| ------------------- | ------ | ---------------- |
| HTTP\_AUTHORIZATION | string | Bearer JWT.TOKEN |

{% tabs %}
{% tab title="200 Return user information" %}

```
{
    "id": 1,
    "username": "test", 
    "first_name": "",
    "last_name": "", 
    "email": "test@test.com"
}
```

{% endtab %}

{% tab title="401 JWT token is invalid" %}

```
```

{% endtab %}
{% endtabs %}

## Update user profile info

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/accounts/profile/`

#### Headers

| Name                | Type   | Description      |
| ------------------- | ------ | ---------------- |
| HTTP\_AUTHORIZATION | string | Bearer JWT.TOKEN |

#### Request Body

| Name        | Type   | Description         |
| ----------- | ------ | ------------------- |
| email       | string | Email to change     |
| Last name   | string | Lastname to change  |
| first\_name | string | Firstname to change |
| username    | string | Username to change  |

{% tabs %}
{% tab title="200 Return updated information" %}

```
{
    "id": 1,
    "username": "test", 
    "first_name": "",
    "last_name": "", 
    "email": "test@test.com"
}
```

{% endtab %}

{% tab title="401 JWT token is invalid" %}

```
```

{% endtab %}
{% endtabs %}

## Change user password

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/accounts/change-password/`

#### Headers

| Name                | Type   | Description      |
| ------------------- | ------ | ---------------- |
| HTTP\_AUTHORIZATION | string | Bearer JWT.TOKEN |

#### Request Body

| Name              | Type   | Description                       |
| ----------------- | ------ | --------------------------------- |
| password\_confirm | string | New password confirmation         |
| password          | string | New password                      |
| old\_password     | string | Old password for security reasons |

{% tabs %}
{% tab title="200 " %}

```
{}
```

{% endtab %}
{% endtabs %}

## Update user email

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/accounts/register-email/`

Send a verification link to a user new email

#### Headers

| Name                | Type   | Description      |
| ------------------- | ------ | ---------------- |
| HTTP\_AUTHORIZATION | string | Bearer JWT.TOKEN |

#### Request Body

| Name  | Type   | Description    |
| ----- | ------ | -------------- |
| email | string | New user email |

{% tabs %}
{% tab title="200 " %}

```
{}
```

{% endtab %}
{% endtabs %}

## Verify new user email

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/account/verify-email/`

Verify new user email from verification link

#### Headers

| Name                | Type   | Description      |
| ------------------- | ------ | ---------------- |
| HTTP\_AUTHORIZATION | string | Bearer JWT.TOKEN |

#### Request Body

| Name      | Type   | Description                                |
| --------- | ------ | ------------------------------------------ |
| signature | string | HMAC request signature                     |
| timestam  | string | Timestamp when user requested email change |
| email     | string | New user email                             |
| user\_id  | string | Django model user ID                       |

{% tabs %}
{% tab title="200 New user email was set" %}

```
{}
```

{% endtab %}
{% endtabs %}

### User registration and verification

![](/files/-MMoZ-4aVQPVC3IQMYNe)

### User login

![](/files/-MMpUd329yhKqLWhpcwt)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openup.gitbook.io/cape-agulhas-app/api/accounts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
