Skip to main content

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

ParameterTypeRequiredDescription
textstringYesThe affirmation text (3-255 characters)

Request Headers

HeaderValueRequired
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes
AuthorizationBearer YOUR_API_TOKENYes

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

ParameterTypeRequiredDescription
textstringYesThe affirmation text (3-255 characters)

Request Headers

HeaderValueRequired
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes
AuthorizationBearer YOUR_API_TOKENYes

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

HeaderValueRequired
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes
AuthorizationBearer YOUR_API_TOKENYes

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

  1. Get the user's API token from storage
  2. 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
  3. To update an affirmation:
    • Validate the new text
    • Make PATCH request to /api/home/custom-affirmations/{id}
    • Update UI with the modified text
  4. To delete an affirmation:
    • Show confirmation dialog
    • Make DELETE request to /api/home/custom-affirmations/{id}
    • Remove item from UI
  5. Handle errors:
    • If unauthorized, redirect to login
    • If subscription required, show upgrade prompt
    • Show validation error messages
    • Update UI state accordingly