# Create Opportunity — Lever

> Creates a new opportunity (candidate + application) in Lever. Use this to add a new candidate to the pipeline, optionally applying them to a specific job posting. Use List Postings to find posting IDs, List Stages to find stage IDs, and…

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

## Description

Creates a new opportunity (candidate + application) in Lever. Use this to add a new candidate to the pipeline, optionally applying them to a specific job posting. Use **List Postings** to find posting IDs, **List Stages** to find stage IDs, and **List Users** to find the recruiter user ID for Perform As. Perform As is required — it sets the opportunity creator and owner. If a candidate with the same email already exists, Lever will link the new opportunity to the existing contact rather than creating a duplicate. WARNING: only one posting UID may be specified per request. Example: to add Jane Doe as a referred candidate on a posting, call with performAs="<userId>", candidateName="Jane Doe", email="jane@example.com", postingId="<postingId>", origin="referred" → returns the created opportunity with its `id`. [See the documentation](https://hire.lever.co/developer/documentation#create-an-opportunity)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `performAs` | `string` | Yes | User ID of the recruiter creating this opportunity — sets the creator and default owner. Use List Users to find user IDs. |
| `candidateName` | `string` | Yes | Full name of the candidate. |
| `headline` | `string` | No | Current job title and company (e.g. Senior Engineer at Acme Corp). |
| `email` | `string` | No | Candidate's email address. Used for deduplication — if a contact with this email already exists, the opportunity will be linked to them. |
| `phone` | `string` | No | Candidate's phone number. |
| `postingId` | `string` | No | Job posting to apply this candidate to. Use List Postings to find posting IDs. Only one posting per request. |
| `stageId` | `string` | No | Initial pipeline stage. Use List Stages to find stage IDs. Defaults to 'New Lead' if omitted. |
| `origin` | `string` | No | How the candidate entered the pipeline (e.g. referred, sourced, applied). |
| `tags` | `string` | No | Comma-separated list of tags to apply (e.g. python,senior,remote). |
| `sources` | `string` | No | Comma-separated list of sources (e.g. LinkedIn,Referral). |
| `links` | `string` | No | Comma-separated list of URLs to social profiles or portfolio (e.g. https://linkedin.com/in/jane,https://github.com/jane). |

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

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: "lever-create-opportunity",
  arguments: {
    performAs: "Perform As (User ID)",
    candidateName: "Candidate Name",
  },
})
```

**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: "lever-create-opportunity",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    lever: { authProvisionId: "apn_xxxxxxx" },
    performAs: "Perform As (User ID)",
    candidateName: "Candidate Name",
  },
})

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": "lever-create-opportunity",
    "configured_props": {
      "lever": { "authProvisionId": "apn_xxxxxxx" },
      "performAs": "Perform As (User ID)",
      "candidateName": "Candidate Name"
    }
  }'
```

---

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