## Create Route `client.workers.routes.create(RouteCreateParamsparams, RequestOptionsoptions?): RouteCreateResponse` **post** `/zones/{zone_id}/workers/routes` Creates a route that maps a URL pattern to a Worker. ### Parameters - `params: RouteCreateParams` - `zone_id: string` Path param: Identifier. - `pattern: string` Body param: Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Body param: Name of the script to run if the route matches. ### Returns - `RouteCreateResponse` - `id: string` Identifier. - `pattern: string` Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior). - `script?: string` Name of the script to run if the route matches. ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const route = await client.workers.routes.create({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', pattern: 'example.com/*', }); console.log(route.id); ``` #### 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": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "pattern": "example.com/*", "script": "my-workers-script" }, "success": true } ```