POST
/
api
/
create-emoji
Create/Update User Emoji
curl --request POST \
  --url https://onlyautomator.com/api/create-emoji \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '{
  "emoji": "😊"
}'
{
  "status": 200,
  "message": "Emoji updated successfully",
  "emoji": {
    "id": "uuid",
    "user_id": "uuid",
    "emoji": "😊"
  }
}
Sets or modifies the custom emoji preference for the authenticated user in the emojis table. If a record exists for the user, it’s updated; otherwise, a new record is created.

Authentication

This endpoint requires authentication via bearer token representing a valid user session managed by Supabase Auth (cookies).Testing Note: Requires user session.
Retrieving JWT Token: (Refer to other endpoints for instructions)

Request

Authorization
string
required
Bearer token for authentication. Format: Bearer YOUR_JWT_TOKEN
emoji
string
required
The string representing the user’s chosen emoji or emoji configuration.

Response

status
number
HTTP status code (e.g., 200).
message
string
A descriptive message about the result (e.g., “Emoji updated successfully”).
emoji
object
The created or updated emoji data object from the emojis table.

Error Codes

Status CodeDescriptionExample Message
400Missing or invalid emoji field in body.”Missing required fields”
401Invalid or missing authentication token.”Not authorized”
500Internal server error during processing.”Failed to process request”
500Database error during insert/update.Specific DB error

Notes

  • Performs an “upsert” operation.
  • Assumes an emojis table exists.

Code Examples

// Using fetch
const saveUserEmoji = async (emojiString, apiToken) => {
  const response = await fetch(`https://onlyautomator.com/api/create-emoji`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${apiToken}`
    },
    body: JSON.stringify({ emoji: emojiString })
  });

  if (!response.ok) {
     const errorData = await response.json();
     throw new Error(`API Error (${response.status}): ${errorData.error || 'Unknown error'}`);
  }
  return await response.json();
};

// Example usage
saveUserEmoji('😊', 'your_api_token')
  .then(data => console.log('Emoji saved:', data.emoji))
  .catch(error => console.error('Error saving emoji:', error));

Headers

Authorization
string
required

Bearer token for authentication (JWT)

Body

application/json
emoji
string
required

The string or JSON representing the user's chosen emoji configuration.

Example:

"😊"

Response

Emoji created or updated successfully.

status
number
Example:

200

message
string
Example:

"Emoji updated successfully"

emoji
object
Example:
{
"id": "uuid",
"user_id": "uuid",
"emoji": "😊"
}