define.wtf
API Reference

Response Format

Standard API response envelopes, error handling, and status codes

Response Format

All define.wtf API responses follow a consistent envelope structure. Every response is a JSON object with success and either data or error fields.

Success Response

Successful requests return 200 OK, 201 Created, or 204 No Content with a success envelope:

{
  "success": true,
  "data": {
    "id": "acr_abc123def456",
    "term": "API",
    "primaryDefinition": {
      "id": "def_xyz789",
      "title": "Application Programming Interface",
      "text": "A set of protocols and tools for building software applications."
    },
    "definitions": [...],
    "categories": [...],
    "createdAt": "2024-01-15T10:30:00Z",
    "updatedAt": "2024-01-15T10:30:00Z"
  },
  "meta": {
    "page": 1,
    "limit": 20,
    "total": 156,
    "hasMore": true
  }
}

Response Fields

  • successboolean Always true for successful responses
  • dataobject | array The requested resource(s)
  • metaobject (optional) Pagination and list metadata (only on list endpoints)

Metadata

List endpoints include pagination information in meta:

{
  "meta": {
    "page": 1,
    "limit": 20,
    "total": 156,
    "hasMore": true
  }
}
  • page — Current page number (1-indexed)
  • limit — Items returned per page
  • total — Total items across all pages
  • hasMoretrue if more pages exist

Error Response

Failed requests return an appropriate HTTP status code (4xx or 5xx) with an error envelope:

{
  "success": false,
  "error": {
    "code": "ACRONYM_NOT_FOUND",
    "message": "Acronym not found"
  }
}

Error Fields

  • successboolean Always false for error responses
  • error.codestring Machine-readable error code (all caps, snake_case)
  • error.messagestring Human-readable error description
  • error.detailsobject (optional) Additional context

Common Error Codes

HTTP StatusError CodeMeaning
400VALIDATION_ERRORInvalid request body or query parameters
400PROFANITY_DETECTEDContent contains inappropriate language
400TENANT_REQUIREDTenant context could not be determined
401UNAUTHORIZEDMissing or invalid session
403FORBIDDENInsufficient permissions
404ACRONYM_NOT_FOUNDRequested acronym does not exist
404DEFINITION_NOT_FOUNDRequested definition does not exist
404CATEGORY_NOT_FOUNDRequested category does not exist
404COLLECTION_NOT_FOUNDRequested collection does not exist
409DUPLICATE_ACRONYMAcronym already exists
409DUPLICATE_CATEGORYCategory name already exists
429RATE_LIMIT_EXCEEDEDToo many requests
500INTERNAL_ERRORUnexpected server error

Validation Error Details

When validation fails (400 Bad Request), the error includes field-level details:

{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request body",
    "details": {
      "term": ["String must contain at most 20 character(s)"],
      "title": ["Required"],
      "categoryIds": ["Expected array, received string"]
    }
  }
}

The details object maps field names to arrays of error messages. Use these to provide targeted feedback to users.

Profanity Detection Details

When profanity is detected (400 Bad Request), the error includes flagged fields:

{
  "success": false,
  "error": {
    "code": "PROFANITY_DETECTED",
    "message": "Content contains inappropriate language",
    "details": {
      "fields": ["title", "text"]
    }
  }
}

Resubmit with cleaned content, or contact your workspace admin if you believe this was a false positive.

Empty Responses

Some endpoints return 204 No Content on success (typically DELETE operations). These requests have an empty response body but include the standard HTTP status code:

HTTP/1.1 204 No Content

No JSON body is returned.

Null vs. Missing Fields

  • Null fields — An optional field that has been explicitly set to null (e.g., no primary definition)
  • Missing fields — An optional field that isn't included in the response (preferred for client-side efficiency)

Both represent "no value". If a field is present, it is guaranteed to be of the declared type.

Example: Creating an Acronym

Request:

curl -X POST https://engineering.define.wtf/api/v1/acronyms \
  -H "Cookie: next-auth.session-token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "term": "API",
    "title": "Application Programming Interface",
    "text": "A set of protocols for building software."
  }'

Success Response (201 Created):

{
  "success": true,
  "data": {
    "acronym": {
      "id": "acr_abc123def456",
      "term": "API",
      "primaryDefinition": {
        "id": "def_xyz789",
        "title": "Application Programming Interface",
        "text": "A set of protocols for building software."
      },
      "definitions": [
        {
          "id": "def_xyz789",
          "title": "Application Programming Interface",
          "isPrimary": true,
          "netVotes": 0
        }
      ],
      "categories": [],
      "definitionCount": 1,
      "totalVotes": 0,
      "isLocked": false,
      "isDeprecated": false,
      "createdAt": "2024-01-15T10:30:00Z",
      "updatedAt": "2024-01-15T10:30:00Z"
    },
    "definition": {
      "id": "def_xyz789",
      "acronymId": "acr_abc123def456",
      "title": "Application Programming Interface",
      "text": "A set of protocols for building software.",
      "isPrimary": true
    }
  }
}

Error Response (400 Bad Request):

{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request body",
    "details": {
      "title": ["Required"]
    }
  }
}

Best Practices

  1. Always check success before accessing data
  2. Use error codes (not messages) to handle errors programmatically
  3. Check metadata to determine if more pages exist
  4. Handle 429 responses with exponential backoff
  5. Don't assume a field is present; check before accessing it