or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.mdlegacy-constants.mdreason-phrases.mdstatus-codes.mdutility-functions.md
tile.json

status-codes.mddocs/

Status Code Constants

Enumerated constants for all standard HTTP status codes with descriptive names, comprehensive documentation, and RFC references.

Capabilities

StatusCodes Enum

The primary interface for accessing HTTP status code constants as numeric values.

/**
 * Enumerated HTTP status code constants
 * Contains all standard status codes from multiple RFCs
 */
enum StatusCodes {
  // 1xx Informational Responses
  /** Continue - client should continue with request */
  CONTINUE = 100,
  /** Switching Protocols - server switching to different protocol */
  SWITCHING_PROTOCOLS = 101,
  /** Processing - server has received and is processing request */
  PROCESSING = 102,
  /** Early Hints - server likely to send final response with included headers */
  EARLY_HINTS = 103,

  // 2xx Success
  /** OK - request has succeeded */
  OK = 200,
  /** Created - request succeeded and new resource created */
  CREATED = 201,
  /** Accepted - request received but not yet acted upon */
  ACCEPTED = 202,
  /** Non-Authoritative Information - meta-information not from origin server */
  NON_AUTHORITATIVE_INFORMATION = 203,
  /** No Content - no content to send but headers may be useful */
  NO_CONTENT = 204,
  /** Reset Content - tells user agent to reset document view */
  RESET_CONTENT = 205,
  /** Partial Content - response to range header for partial download */
  PARTIAL_CONTENT = 206,
  /** Multi-Status - conveys information about multiple resources */
  MULTI_STATUS = 207,

  // 3xx Redirection
  /** Multiple Choices - request has more than one possible response */
  MULTIPLE_CHOICES = 300,
  /** Moved Permanently - URI of requested resource changed permanently */
  MOVED_PERMANENTLY = 301,
  /** Moved Temporarily - URI changed temporarily */
  MOVED_TEMPORARILY = 302,
  /** See Other - direct client to get resource with GET request */
  SEE_OTHER = 303,
  /** Not Modified - response has not been modified (caching) */
  NOT_MODIFIED = 304,
  /** Use Proxy - must be accessed by proxy (deprecated) */
  USE_PROXY = 305,
  /** Temporary Redirect - resource moved temporarily, same method required */
  TEMPORARY_REDIRECT = 307,
  /** Permanent Redirect - resource moved permanently, same method required */
  PERMANENT_REDIRECT = 308,

  // 4xx Client Errors
  /** Bad Request - server cannot understand request due to invalid syntax */
  BAD_REQUEST = 400,
  /** Unauthorized - client must authenticate to get requested response */
  UNAUTHORIZED = 401,
  /** Payment Required - reserved for future use */
  PAYMENT_REQUIRED = 402,
  /** Forbidden - client does not have access rights to content */
  FORBIDDEN = 403,
  /** Not Found - server cannot find requested resource */
  NOT_FOUND = 404,
  /** Method Not Allowed - request method disabled and cannot be used */
  METHOD_NOT_ALLOWED = 405,
  /** Not Acceptable - no content following user agent criteria */
  NOT_ACCEPTABLE = 406,
  /** Proxy Authentication Required - authentication needed by proxy */
  PROXY_AUTHENTICATION_REQUIRED = 407,
  /** Request Timeout - server would like to shut down unused connection */
  REQUEST_TIMEOUT = 408,
  /** Conflict - request conflicts with current server state */
  CONFLICT = 409,
  /** Gone - requested content permanently deleted from server */
  GONE = 410,
  /** Length Required - Content-Length header field required */
  LENGTH_REQUIRED = 411,
  /** Precondition Failed - client indicated preconditions not met */
  PRECONDITION_FAILED = 412,
  /** Request Entity Too Large - request entity larger than server limits */
  REQUEST_TOO_LONG = 413,
  /** Request-URI Too Long - URI longer than server willing to interpret */
  REQUEST_URI_TOO_LONG = 414,
  /** Unsupported Media Type - media format of requested data not supported */
  UNSUPPORTED_MEDIA_TYPE = 415,
  /** Requested Range Not Satisfiable - range in Range header cannot be fulfilled */
  REQUESTED_RANGE_NOT_SATISFIABLE = 416,
  /** Expectation Failed - expectation in Expect header cannot be met */
  EXPECTATION_FAILED = 417,
  /** I'm a teapot - attempt to brew coffee with a teapot */
  IM_A_TEAPOT = 418,
  /** Insufficient Space on Resource - insufficient storage to complete request */
  INSUFFICIENT_SPACE_ON_RESOURCE = 419,
  /** Method Failure - method failed (deprecated Spring Framework response) */
  METHOD_FAILURE = 420,
  /** Misdirected Request - server cannot produce response for scheme/authority combination */
  MISDIRECTED_REQUEST = 421,
  /** Unprocessable Entity - request well-formed but unable to follow due to semantic errors */
  UNPROCESSABLE_ENTITY = 422,
  /** Locked - resource being accessed is locked */
  LOCKED = 423,
  /** Failed Dependency - request failed due to failure of previous request */
  FAILED_DEPENDENCY = 424,
  /** Upgrade Required - server refuses current protocol but may accept after upgrade */
  UPGRADE_REQUIRED = 426,
  /** Precondition Required - origin server requires request to be conditional */
  PRECONDITION_REQUIRED = 428,
  /** Too Many Requests - user sent too many requests in given time */
  TOO_MANY_REQUESTS = 429,
  /** Request Header Fields Too Large - server unwilling to process due to large header fields */
  REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
  /** Unavailable For Legal Reasons - resource cannot legally be provided */
  UNAVAILABLE_FOR_LEGAL_REASONS = 451,

  // 5xx Server Errors
  /** Internal Server Error - server encountered unexpected condition */
  INTERNAL_SERVER_ERROR = 500,
  /** Not Implemented - request method not supported by server */
  NOT_IMPLEMENTED = 501,
  /** Bad Gateway - server got invalid response while acting as gateway */
  BAD_GATEWAY = 502,
  /** Service Unavailable - server not ready to handle request */
  SERVICE_UNAVAILABLE = 503,
  /** Gateway Timeout - server acting as gateway cannot get response in time */
  GATEWAY_TIMEOUT = 504,
  /** HTTP Version Not Supported - HTTP version in request not supported */
  HTTP_VERSION_NOT_SUPPORTED = 505,
  /** Insufficient Storage - server unable to store representation needed */
  INSUFFICIENT_STORAGE = 507,
  /** Network Authentication Required - client needs to authenticate to gain network access */
  NETWORK_AUTHENTICATION_REQUIRED = 511
}

Usage Examples:

import { StatusCodes } from "http-status-codes";

// Express.js response
app.get("/users", (req, res) => {
  res.status(StatusCodes.OK).json(users);
});

// Error handling
if (user === null) {
  return res.status(StatusCodes.NOT_FOUND).json({
    error: "User not found"
  });
}

// Conditional logic based on status codes
switch (response.status) {
  case StatusCodes.OK:
    return response.data;
  case StatusCodes.NOT_FOUND:
    throw new Error("Resource not found");
  case StatusCodes.INTERNAL_SERVER_ERROR:
    throw new Error("Server error");
}

// Type-safe status code checking
const isSuccessStatus = (status: number): boolean => {
  return status >= StatusCodes.OK && status < StatusCodes.MULTIPLE_CHOICES;
};

RFC Standards Coverage

The StatusCodes enum includes all status codes from:

  • RFC1945 (HTTP/1.0): Basic HTTP status codes
  • RFC2616 (HTTP/1.1): Standard HTTP/1.1 status codes
  • RFC2518 (WebDAV): Web Distributed Authoring and Versioning extensions
  • RFC6585 (Additional HTTP Status Codes): Additional standard status codes
  • RFC7538 (Permanent Redirect): 308 Permanent Redirect status code