# Create Draft Return Order — Returnista

> Creates a new draft return order for a consumer. Draft return orders are pending merchant review before being accepted or rejected. Use Process Draft Return Order to accept or reject the created draft. See the documentation

- Key: `returnista-create-draft-return-order`
- Type: Action (Write)
- Version: 0.0.2
- App: Returnista (`returnista`) — https://pipedream.com/apps/returnista.md
- This page (HTML): https://pipedream.com/apps/returnista/actions/create-draft-return-order
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/returnista/actions/create-draft-return-order/create-draft-return-order.mjs

## Description

Creates a new draft return order for a consumer. Draft return orders are pending merchant review before being accepted or rejected. Use **Process Draft Return Order** to accept or reject the created draft. [See the documentation](https://platform.returnista.com/reference/rest-api/#post-/consumer/-consumerId-/draft-return-order)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `consumerId` | `string` | Yes | The unique identifier of the consumer in Returnista. To find a consumer ID, use Get Return Orders or Get Return Order — the consumer ID is included directly in the response. |
| `purchaseId` | `string` | Yes | The ID of the purchase to return. Use Get Consumer Purchases to find purchase IDs. |
| `returnReasonId` | `string` | No | The UUID of the return reason. Use Get Return Reasons to find available IDs. Leave blank to submit without a reason (sends null). |
| `returnReasonComment` | `string` | No | An optional free-text comment explaining the return reason. |
| `resolutionType` | `string` | No | The desired resolution type for the return. |
| `exchangeProductId` | `string` | No | The ID of the shipping product to exchange for. Typically required when resolutionType is Exchange. Use List Shipping Products to find available product IDs. |
| `exchangeOptionSku` | `string` | No | The SKU of the product variant to exchange for. Typically required when resolutionType is Exchange. |
| `answers` | `string[]` | No | Array of form field answers for the return questionnaire. Each entry is a stringified JSON object with formField and answer. Example entry: {"formField":{"id":"uuid-here","type":"SingleChoice","required":true},"answer":"value"}. answer can also be an array of strings (MultiChoice) or an array of file objects: [{"mimeType":"image/jpeg","url":"https://..."}]. |

## 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": "returnista",
      },
    },
  },
)

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: "returnista-create-draft-return-order",
  arguments: {
    consumerId: "Consumer ID",
    purchaseId: "Purchase 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: "returnista-create-draft-return-order",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    returnista: { authProvisionId: "apn_xxxxxxx" },
    consumerId: "Consumer ID",
    purchaseId: "Purchase 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": "returnista-create-draft-return-order",
    "configured_props": {
      "returnista": { "authProvisionId": "apn_xxxxxxx" },
      "consumerId": "Consumer ID",
      "purchaseId": "Purchase ID"
    }
  }'
```

---

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