# Create Availability Block — Mews

> Create an availability block in Mews. See the documentation

- Key: `mews-create-availability-block`
- Type: Action (Write)
- Version: 0.0.3
- App: Mews (`mews`) — https://pipedream.com/apps/mews.md
- This page (HTML): https://pipedream.com/apps/mews/actions/create-availability-block
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/mews/actions/create-availability-block/create-availability-block.mjs

## Description

Create an availability block in Mews. [See the documentation](https://mews-systems.gitbook.io/connector-api/operations/availabilityblocks#add-availability-blocks)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `serviceId` | `string` | Yes | Unique identifier of the Service to assign block to. Options are loaded from the connected account. |
| `rateId` | `string` | Yes | Unique identifier of the Rate to assign block to. Options are loaded from the connected account. |
| `firstTimeUnitStartUtc` | `string` | Yes | Start of the time interval, expressed as the timestamp for the start of the first time unit, in UTC timezone ISO 8601 format. Eg. 2025-01-01T00:00:00Z |
| `lastTimeUnitStartUtc` | `string` | Yes | End of the time interval, expressed as the timestamp for the start of the first time unit, in UTC timezone ISO 8601 format. Eg. 2025-01-01T00:00:00Z |
| `state` | `string` | Yes | State of the availability block. |
| `releasedUtc` | `string` | No | The moment when the block and its availability is released, in UTC timezone ISO 8601 format. Takes precedence over RollingReleaseOffset. Eg. 2025-01-01T00:00:00Z |
| `name` | `string` | No | The name of the block. |
| `bookerId` | `string` | No | Unique identifier of the Booker as a creator of an availability block. Options are loaded from the connected account. |
| `companyId` | `string` | No | Unique identifier of Company. Options are loaded from the connected account. |
| `travelAgencyId` | `string` | No | Identifier of the Travel Agency. (Company with a TravelAgencyContract) Options are loaded from the connected account. |
| `budgetCurrency` | `string` | No | Currency of the budget. Options are loaded from the connected account. |
| `budgetValue` | `string` | No | The value of the budget. |
| `reservationPurpose` | `string` | No | The purpose of the block. |
| `externalIdentifier` | `string` | No | Identifier of the block from external system. Max length 255 characters. |
| `notes` | `string` | No | Additional notes of the block. |
| `quoteId` | `string` | No | Unique identifier of the Mews Events quote associated with the availability block. |
| `purchaseOrderNumber` | `string` | No | Unique number of the purchase order. This number is propagated to any newly picked up Reservation within the block. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "mews",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "mews-create-availability-block",
  arguments: {
    serviceId: "Service ID",
    rateId: "Rate ID",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "mews-create-availability-block",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    mews: { authProvisionId: "apn_xxxxxxx" },
    serviceId: "Service ID",
    rateId: "Rate ID",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "mews-create-availability-block",
    "configured_props": {
      "mews": { "authProvisionId": "apn_xxxxxxx" },
      "serviceId": "Service ID",
      "rateId": "Rate ID"
    }
  }'
```

---

- App: https://pipedream.com/apps/mews.md · All apps: https://pipedream.com/apps
