Custom Affirmations
Custom Affirmations allow users to create, manage, and personalize their own affirmation texts. These affirmations are tied to the user's intention and can be used to reinforce positive thoughts and goals.
Note: These endpoints require an active subscription.
Create Custom Affirmation
Create a new personalized affirmation text. The affirmation will be associated with the user's current intention.
Endpoint
- Method: POST
- URL:
/api/home/custom-affirmations
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | The affirmation text (3-255 characters) |
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
| Authorization | Bearer YOUR_API_TOKEN | Yes |
Success Response
{
"success": true,
"message": "Data has been created successfully",
"data": {
"id": 1,
"text": "Your custom affirmation"
},
"status_code": 201
}
Error Responses
Unauthorized (401)
{
"success": false,
"message": "Unauthenticated",
"data": null,
"status_code": 401
}
Subscription Required (403)
{
"success": false,
"message": "Subscription required",
"data": null,
"status_code": 403
}
Validation Error (422)
{
"success": false,
"message": "The text field is required",
"data": null,
"status_code": 422
}
Update Custom Affirmation
Modify an existing custom affirmation text. Only the owner of the affirmation can update it.
Endpoint
- Method: PATCH
- URL:
/api/home/custom-affirmations/{id}
Where {id} is the ID of the custom affirmation to update.
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | The affirmation text (3-255 characters) |
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
| Authorization | Bearer YOUR_API_TOKEN | Yes |
Success Response
{
"success": true,
"message": "Data has been updated successfully",
"data": {
"id": 1,
"text": "Your updated custom affirmation"
},
"status_code": 200
}
Error Responses
Unauthorized (401)
{
"success": false,
"message": "Unauthenticated",
"data": null,
"status_code": 401
}
Subscription Required (403)
{
"success": false,
"message": "Subscription required",
"data": null,
"status_code": 403
}
Not Found (404)
{
"success": false,
"message": "Custom affirmation not found",
"data": null,
"status_code": 404
}
Validation Error (422)
{
"success": false,
"message": "The text must be at least 3 characters",
"data": null,
"status_code": 422
}
Delete Custom Affirmation
Permanently remove a custom affirmation. This action cannot be undone. Only the owner of the affirmation can delete it.
Endpoint
- Method: DELETE
- URL:
/api/home/custom-affirmations/{id}
Where {id} is the ID of the custom affirmation to delete.
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
| Authorization | Bearer YOUR_API_TOKEN | Yes |
Success Response
{
"success": true,
"message": "Data has been deleted successfully",
"data": null,
"status_code": 200
}
Error Responses
Unauthorized (401)
{
"success": false,
"message": "Unauthenticated",
"data": null,
"status_code": 401
}
Subscription Required (403)
{
"success": false,
"message": "Subscription required",
"data": null,
"status_code": 403
}
Not Found (404)
{
"success": false,
"message": "Custom affirmation not found",
"data": null,
"status_code": 404
}
Example Implementation Flow
- Get the user's API token from storage
- To create a custom affirmation:
- Validate the text length (3-255 characters)
- Make POST request to
/api/home/custom-affirmations - Display success message and update UI
- To update an affirmation:
- Validate the new text
- Make PATCH request to
/api/home/custom-affirmations/{id} - Update UI with the modified text
- To delete an affirmation:
- Show confirmation dialog
- Make DELETE request to
/api/home/custom-affirmations/{id} - Remove item from UI
- Handle errors:
- If unauthorized, redirect to login
- If subscription required, show upgrade prompt
- Show validation error messages
- Update UI state accordingly