# Assets ## Upsert asset hashes `client.pages.assets.upsertHashes(AssetUpsertHashesParamsbody, RequestOptionsoptions?): AssetUpsertHashesResponse` **post** `/pages/assets/upsert-hashes` Register the provided file hashes as recently uploaded to the Pages asset store. Used as part of the Pages Direct Upload workflow so future deployments can avoid re-uploading files that are already present. Authenticate with the JWT obtained from the upload-token endpoint: GET /accounts/{account_id}/pages/projects/{project_name}/upload-token ### Parameters - `body: AssetUpsertHashesParams` - `hashes: Array` List of file content hashes to register in the asset store. ### Returns - `AssetUpsertHashesResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare(); const response = await client.pages.assets.upsertHashes({ hashes: ['a948904f2f0f479b8f936b8a0c5d9882', 'b026324c6904b2a9cb4b88d6d61c81d1'], }); console.log(response.errors); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true } ``` ## Check missing assets `client.pages.assets.checkMissing(AssetCheckMissingParamsbody, RequestOptionsoptions?): SinglePage` **post** `/pages/assets/check-missing` Check which of the provided file hashes are missing from the Pages asset store. Returns a list of missing hashes that need to be uploaded. Used as part of the Pages Direct Upload workflow. Authenticate with the JWT obtained from the upload-token endpoint: GET /accounts/{account_id}/pages/projects/{project_name}/upload-token ### Parameters - `body: AssetCheckMissingParams` - `hashes: Array` List of file content hashes to check for existence in the asset store. ### Returns - `AssetCheckMissingResponse = string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare(); // Automatically fetches more pages as needed. for await (const assetCheckMissingResponse of client.pages.assets.checkMissing({ hashes: ['a948904f2f0f479b8f936b8a0c5d9882', 'b026324c6904b2a9cb4b88d6d61c81d1'], })) { console.log(assetCheckMissingResponse); } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ "b026324c6904b2a9cb4b88d6d61c81d1" ], "success": true } ``` ## Upload asset `client.pages.assets.upload(AssetUploadParamsparams, RequestOptionsoptions?): AssetUploadResponse` **post** `/pages/assets/upload` Upload one or more files to the Pages asset store. Each file is identified by its content hash and is uploaded using the same JSON shape as the Cloudflare KV bulk write API. Used as part of the Pages Direct Upload workflow. Authenticate with the JWT obtained from the upload-token endpoint: GET /accounts/{account_id}/pages/projects/{project_name}/upload-token ### Parameters - `params: AssetUploadParams` - `body: Array` - `base64: boolean` Whether value is base64 encoded. - `key: string` File content hash used as the object key in the Pages asset store. - `metadata: Metadata` - `contentType: string` MIME type for the uploaded file. - `value: string` File content. When base64 is true, this value is base64 encoded. ### Returns - `AssetUploadResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare(); const response = await client.pages.assets.upload({ body: [ { base64: true, key: 'b026324c6904b2a9cb4b88d6d61c81d1', metadata: { contentType: 'text/plain' }, value: 'SGVsbG8sIFdvcmxkIQ==', }, ], }); console.log(response.errors); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true } ``` ## Domain Types ### Asset Upsert Hashes Response - `AssetUpsertHashesResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true` ### Asset Check Missing Response - `AssetCheckMissingResponse = string` ### Asset Upload Response - `AssetUploadResponse` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `success: true` Whether the API call was successful. - `true`