Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Uploads filter

Create a new filter

Body parameters

id string Optional

RFC 4122 UUID of upload filter expressed in URL-safe base64 format

Example: "-Lo34LFSTLmgPToamzJLcg"
name string Required

The name of the filter

Example: "Draft posts"
filter object Required

The actual filter

Example: { status: { eq: "draft" } }
shared boolean Required

Whether it's a shared filter or not

Returns

Returns a resource object of type upload_filter

Examples

1
import { buildClient } from "@datocms/cma-client-node";
2
3
async function run() {
4
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
5
6
const uploadFilter = await client.uploadFilters.create({
7
name: "Draft posts",
8
filter: { status: { eq: "draft" } },
9
shared: true,
10
});
11
12
// Check the 'Returned output' tab for the result ☝️
13
console.log(uploadFilter);
14
}
15
16
run();
1
{
2
id: "-Lo34LFSTLmgPToamzJLcg",
3
name: "Draft posts",
4
filter: { status: { eq: "draft" } },
5
shared: true,
6
}