Skip to main content
While the Notion SDK provides convenient methods for all standard API endpoints, you can use the client.request() method to make custom API calls. This is useful for:
  • Testing new Notion API features before the SDK is updated
  • Debugging API responses
  • Building custom wrappers or abstractions
  • Working with beta or experimental endpoints

The request() Method

The request() method is the low-level foundation that all SDK methods use internally.

Method Signature

RequestParameters

Making Custom Requests

GET Request Example

Retrieve a page using the low-level API:

POST Request Example

Create a page with a custom request:

PATCH Request Example

Update a block:

DELETE Request Example

Delete a block:

Query Parameters

Pass query parameters using the query option:

Custom Headers

Add custom headers to your request:
The SDK automatically adds required headers like Notion-Version, Authorization, and Content-Type. You don’t need to include these manually.

Request-Level Authentication

Override the client’s default authentication for a single request:

OAuth Authentication

For OAuth endpoints, pass client credentials:

Type Safety

You can provide a type parameter for the response:
Or import types from the SDK:

Error Handling

The request() method throws the same errors as other SDK methods:

Automatic Features

The request() method includes all the built-in SDK features:

Automatic Retries

Rate-limited and server error requests are automatically retried with exponential back-off

Request Timeout

Requests timeout after 60 seconds by default (configurable via timeoutMs in client options)

Version Header

The SDK automatically sets the Notion-Version header to the supported API version

Logging

Requests are logged based on the client’s logLevel setting

Internal Request Flow

Here’s what happens when you call request():
  1. Path Validation - Checks for path traversal attacks (src/Client.ts:239)
  2. URL Construction - Builds full URL with base URL and query parameters (src/Client.ts:243)
  3. Headers - Adds authentication, version, and content-type headers (src/Client.ts:245-249)
  4. Retry Logic - Executes request with automatic retry for transient errors (src/Client.ts:252-258)
  5. Response Parsing - Parses JSON response or throws typed error (src/Client.ts:430-442)

Practical Example: Custom Endpoint

Imagine Notion releases a new beta endpoint for AI summaries:

When to Use request()

If Notion releases a new API endpoint that isn’t yet in the SDK, you can call it immediately using request().
For standard endpoints like pages.retrieve() or databases.query(), use the built-in methods. They provide better type safety and documentation.
The request() method is useful for debugging API responses or testing parameter combinations.

Advanced: Form Data Requests

For file uploads, use formDataParams instead of body:
When using formDataParams, don’t provide a body. The SDK automatically sets the correct multipart/form-data content type.