landmark-flagLabs API

Labs API Reference

The Labs API provides programmatic access to Molecule Labs β€” secure data rooms for managing research files, announcements, and intellectual property. Utilize this API to automate file uploads, integrate with CI/CD pipelines, and build applications on the Molecule ecosystem.

Base URLs

Environment
Endpoint

Production

https://production.graphql.api.molecule.xyz/graphql

Staging

https://staging.graphql.api.molecule.xyz/graphql

Authentication

The API uses a two-tier authentication model:

Operation Type
Required Headers

Queries (read)

x-api-key

Mutations (write)

x-api-key + X-Service-Token

Headers

Read operations

curl -X POST https://production.graphql.api.molecule.xyz/graphql \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"query": "{ projectsV2 { nodes { ipnftUid } } }"}'

Write operations

Obtaining Credentials

Contact the Molecule team via Discordarrow-up-right with:

  • Wallet address

  • Use case description

  • Target Lab (ipnftUid)

  • Desired token expiration

Token Management

Extend token expiration

Revoke token

Core Concepts

IPNFT UID Format

All operations reference Labs by their ipnftUid: {contractAddress}_{tokenId}

  • Example: 0xcaD88677CA87a7815728C72D74B4ff4982d54Fc1_9

Access Levels

Level
Who Can Access

PUBLIC

Anyone

HOLDERS

IP Token holders (requires on-chain verification)

ADMIN

Lab administrators only

Note: HOLDERS access level is accepted by the API but token-gating is not currently enforced. Files marked as HOLDERS behave the same as ADMIN until token-gated access is implemented.

File References

  • path: Human-readable file path (e.g., research/data.csv)

  • ref: Kamu dataset ID (DID) for versioning operations

Pagination

All list queries support cursor-based pagination:

Parameter
Type
Default
Max
Notes

page

Int

0

β€”

0-indexed

perPage

Int

10

100

Items per page

Example:

URL Lifetimes

Queries

List Projects

Retrieve all Labs with pagination.

Get Project with Files

Retrieve a specific Lab with all data room files.

Get File by Path

Retrieve a specific file with download URL.

Project Activity

Retrieve timeline of file events and announcements.

Project Announcements

Retrieve announcements only (more efficient than activity query).

Search Labs

Semantic search across all Labs, files, and announcements.

Global Activity Feed

Retrieve announcements across all Labs.

Mutations

File Upload (3-Step Flow)

Step 1: Initiate Upload

Step 2: Upload to Storage

Step 3: Finalize Upload

For new files β€” use path:

For file versions β€” use ref:

Encrypted File Upload

For confidential files, opt into encryption on initiate (encryption: true) and include encryptionMetadata on finishCreateOrUpdateFileV2. New uploads use Molecule's Onchain-Verified Envelope Encryption β€” the backend issues a one-shot plaintext DEK plus a wrapped DEK; the client AES-256-GCM encrypts locally and stores the wrapped DEK and access conditions in encryptionMetadata. encryptionSystem is backend-set; clients must echo the value returned by initiateCreateOrUpdateFileV2 rather than hardcode it. See Data Privacy & Access for the full flow.

accessControlConditions is a JSON-stringified array of predicates that the backend evaluates against live chain state at decrypt time. To gate decryption on LabNFT owner OR active Contributor OR active Viewer, OR isAuthorizedSignerForTba against hasRole(oclId, :userAddress, ROLE_VIEWER) on AccessResolver β€” :userAddress is substituted with the authenticated caller. The full EvmContractCondition shape and worked JSON examples are documented in Data Privacy & Access β€” Worked Example.

The accessControlConditions string above is abbreviated (functionAbi: {...}) β€” see the worked example for the full ABI block. Substitute <accessresolver-address> with the deployment from the AccessResolver deployments table, <40hex-tba> with the lab's TBA address (lower 20 bytes of oclId), and <20hex-tokenId> with the LabNFT tokenId in 10-byte big-endian hex.

Role Management (on-chain, off this API surface)

Role grants and revokes happen on AccessResolver directly β€” they are on-chain transactions, not Labs API mutations. Lab owners (and active Contributors, for the Viewer slot) call grantRole(oclId, account, role, expiry, isAgent) / revokeRole(oclId, account) through any web3 client (viem / ethers / Safe transaction). See Roles & Permissions for the capability matrix, grant lifecycle, and the isAgent / expiry semantics. The Labs API only consumes role state at decrypt time via the accessControlConditions evaluator.

Encrypted File Upload (Lit Protocol, legacy)

Legacy. The shape below is retained read-only for files encrypted before the migration to Onchain-Verified Envelope Encryption. New uploads use the shape above. Files with this shape continue to decrypt through the Lit SDK.

Update File Metadata

Modify metadata without creating a new version.

Delete File

Permanently remove a file from the data room.

Create Announcement

Share updates with Lab followers.

Create Project

Create a new Lab for an IP-NFT you own.

Telegram Integration

Get passphrase for connecting Telegram bot to Lab.

Types Reference

DataRoom File

Encryption Metadata

Discriminated by encryptionSystem. New files (encryptionSystem = "kms" or "bls") use Onchain-Verified Envelope Encryption; legacy files (encryptionSystem = null / absent) use Lit Protocol. Common fields apply to both.

ProjectV2

InternalLabsError

Error Handling

Error Response Format

Error Codes

Code
HTTP
Description
Retryable

UNAUTHORIZED

401

Invalid or missing API key

No

FORBIDDEN

403

Valid credentials but insufficient permissions

No

NOT_FOUND

404

Lab or file does not exist

No

FILE_EXISTS

400

File path already exists (use ref for versioning)

No

INVALID_INPUT

400

Malformed request parameters

No

UPLOAD_EXPIRED

400

Upload token has expired

Yes (re-initiate)

PAYLOAD_TOO_LARGE

413

File exceeds size limit

No

RATE_LIMITED

429

Too many requests

Yes (with backoff)

INTERNAL_ERROR

500

Server error

Yes

KAMU_ERROR

502

Upstream storage error

Yes

Rate Limits

Tier
Queries/min
Mutations/min
Max File Size
Storage/Lab

Standard

60

20

5 GB

5 GB

Pro

300

100

10 GB

50 GB

Enterprise

Unlimited

500

50 GB

Unlimited

Rate limit headers:

  • X-RateLimit-Limit: 60

  • X-RateLimit-Remaining: 45

  • X-RateLimit-Reset: 1706198400

SDK

Installation

Usage

Complete Example

Last updated