> ## Documentation Index
> Fetch the complete documentation index at: https://dev.ownright.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Making referrals

> A quick how-to guide on sending client referrals to Ownright

To create a referral, make a GraphQL mutation request to our API using one of the
available referral create mutations (e.g. `propertyClosingReferralCreate`). This allows
you to refer a client for a specific type of real estate transaction.

## 🛠️ Steps to create a referral

<Steps>
  <Step title="Choose a referral type and mutation">
    You’ll need to specify the type of referral you'd like to make. Once you know what kind of referral,
    choose to use the appropriate GraphQL mutation:

    | Referral type             | Mutation                        | Notes                                        |
    | ------------------------- | ------------------------------- | -------------------------------------------- |
    | Purchase                  | `propertyClosingReferralCreate` | Supply the `PURCHASE_PROPERTY_CLOSING` type. |
    | Sale                      | `propertyClosingReferralCreate` | Supply the `SALE_PROPERTY_CLOSING` type.     |
    | Refinance                 | `refinanceReferralCreate`       |                                              |
    | Status Certificate Review | `statusCertificateReviewCreate` |                                              |

    <Note>
      Read our [Partner API reference](/partner-api/reference/connecting) for all of the details on each mutation.
    </Note>
  </Step>

  <Step title="Construct the GraphQL mutation with all of the inputs">
    Once you know what type of referral you want to make, you need to construct the
    request with your desired inputs, for example:

    ```graphql Request [expandable] theme={null}
    mutation PropertyClosingReferralCreate {
      propertyClosingReferralCreate(input: {
        type: PURCHASE_PROPERTY_CLOSING,
        contacts: [
          {
            firstName: "John",
            email: "something@something.com",
            primary: true
          }
        ],
        # ... other input
      }) {
        referral {
          id
        }
        userErrors {
          code
          message
        }
      }
    }
    ```
  </Step>

  <Step title="Handle the response">
    On success, the response will include the newly created referral and any fields you have queried for.
    If something goes wrong, check the `userErrors` array for the error code and message (read more about
    errors in our [Errors and response codes](/fundamentals/errors-and-response-codes) documentation)

    ✅ **Example response**

    ```json Successful response [expandable] theme={null}
    {
      "data": {
        "propertyClosingReferralCreate": {
          "referral": {
            "id": "ref_12345"
          },
          "userErrors": []
        }
      }
    }
    ```

    ❌ **Error response**

    ```json Error response [expandable] theme={null}
    {
      "data": {
        "propertyClosingReferralCreate": {
          "referral": null,
          "userErrors": [
            {
              "code": "INVALID_EMAIL",
              "message": "Email must be a valid email address."
            }
          ]
        }
      }
    }
    ```
  </Step>
</Steps>

## 🧠 Tips

<ul>
  <li>Ensure the email is valid and unique for each contact.</li>

  <li>
    You can include multiple contacts, but only one should be marked primary:
    true.
  </li>
</ul>

## Next steps

<CardGroup cols={2}>
  <Card title="Fetching referral details" icon="file-lines" href="/partner-api/guides/fetching-referral-details">
    Retrieve detailed information about a specific referral.
  </Card>

  <Card title="Fetching matter details" icon="gavel" href="/partner-api/guides/fetching-matter-details">
    Track the progress of your client's legal transaction.
  </Card>
</CardGroup>
