Skip to main content

API documentation

The regex101 API exposes a live OpenAPI 3.1 contract and an interactive Swagger UI at regex101.com/api/docs. The contract is generated from the deployed API, so use it as the reference for the paths, fields, and responses that it documents.

The examples below demonstrate two common workspace operations. They do not replace the complete API reference.

For AI clients, use the regex101 MCP server instead of calling these routes directly.

Authentication

The website uses a secure session cookie. Compatible MCP clients use the browser OAuth flow and store the same session credential as a bearer token. See MCP server for connection instructions.

Direct API requests can use the same token. Send it in the Authorization header. A bearer request does not need a Cookie header.

Treat the token like a password. Store it outside source control, use it only over HTTPS, and do not include it in URLs or logs:

Authorization: Bearer <token>

The authenticated examples use REGEX101_TOKEN so that the token does not appear in source code.

Get a workspace

Use the workspace permalink fragment and version from a regex101 URL. Authentication is optional for public workspaces and required when the requested workspace is private. These examples request a public workspace without an Authorization header.

curl --fail-with-body \
"https://regex101.com/api/workspace/$WORKSPACE_ID/$WORKSPACE_VERSION"

An abridged response looks like this:

{
"permalinkFragment": "AbC123",
"version": 1,
"preferredEditorMode": "match",
"regex": "regex\\d+",
"testStrings": [
{
"name": null,
"value": "regex101",
"disabled": false
}
],
"flags": "g",
"delimiter": "/",
"flavor": "pcre2",
"isPrivate": false,
"isEditable": true,
"isOwner": false
}

The full response also contains editor data, permissions, tags, unit tests, and substitution data.

Save a workspace

POST /api/workspace creates a workspace. Add permalinkFragment to the request body to save a new version of an existing workspace.

The examples below require REGEX101_TOKEN, so the new workspace belongs to the signed-in account. To create an anonymous workspace, omit the Authorization header. Anonymous workspaces are controlled through the delete codes returned by the API.

curl --fail-with-body \
--request POST \
--header "Authorization: Bearer $REGEX101_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"regex": "regex\\d+",
"testStrings": [
{
"name": null,
"value": "Try regex101 and regex42",
"disabled": false
}
],
"substitution": null,
"listSubstitution": null,
"unitTests": [],
"flags": "g",
"delimiter": "/",
"flavor": "pcre2"
}' \
"https://regex101.com/api/workspace"

A new workspace returns HTTP 201 with its permalink and delete codes:

{
"permalinkFragment": "AbC123",
"permalinkVersionDeleteCode": "<version-delete-code>",
"permalinkDeleteCode": "<workspace-delete-code>",
"versionDeleteCode": "<version-delete-code>",
"regexDeleteCode": "<workspace-delete-code>",
"version": 1,
"isLibraryEntry": false
}

The versionDeleteCode and regexDeleteCode fields are deprecated compatibility aliases. Use permalinkVersionDeleteCode and permalinkDeleteCode in new integrations.