Users API

This section covers the POST /api/user endpoint, which returns the authenticated user’s profile. It’s part of DocuWriter.ai’s REST API.

Purpose

  • 🔍 Retrieve Profile: Fetches the current user’s account details.
  • 🔒 Secure Access: Only accessible with a valid token.
  • 📊 Minimal Exposure: Only returns safe fields (no passwords or tokens).

Authentication

All requests must include a valid Sanctum token in the Authorization header:

Header Value Required
Authorization Bearer <your_token> Yes

Requests without this header (or with an invalid token) receive a 401 Unauthorized response.


Request

No request body is required. Simply issue a POST to the endpoint with the Authorization header.

curl -X POST https://app.docuwriter.ai/api/user \
-H "Authorization: Bearer <your_token>"

Response Fields

On success (200 OK), the API returns a JSON object with the following fields:

Field Type Description
id integer Unique identifier for the user.
name string Full name of the user.
email string User’s email address.
emailverifiedat string null
created_at string Timestamp when the account was created.
updated_at string Timestamp of the last update.

Error Responses

Status Code Reason Body Example
401 Unauthorized { "message": "Unauthenticated." }
405 Method Not Allowed { "message": "Method Not Allowed." }

{
    "title": "Retrieve Authenticated User",
    "description": "Returns the profile of the currently authenticated user.",
    "method": "POST",
    "baseUrl": "https://app.docuwriter.ai",
    "endpoint": "/api/user",
    "headers": [
        {
            "key": "Authorization",
            "value": "Bearer <your_token>",
            "required": true
        }
    ],
    "queryParams": [],
    "pathParams": [],
    "bodyType": "none",
    "requestBody": "",
    "formData": [],
    "rawBody": "",
    "responses": {
        "200": {
            "description": "User profile retrieved successfully",
            "body": "{\n  \"id\": 1,\n  \"name\": \"Jane Doe\",\n  \"email\": \"[email protected]\",\n  \"email_verified_at\": \"2025-01-10T12:34:56Z\",\n  \"created_at\": \"2024-06-01T08:00:00Z\",\n  \"updated_at\": \"2025-07-15T16:20:00Z\"\n}"
        },
        "401": {
            "description": "Authentication required or token invalid",
            "body": "{\n  \"message\": \"Unauthenticated.\"\n}"
        },
        "405": {
            "description": "Invalid HTTP method used",
            "body": "{\n  \"message\": \"Method Not Allowed.\"\n}"
        }
    }
}