# Add Case Party

Any links you share of active cases which leads to White Swan hosted pages  have their data protected through two factor authentication, and requires clients to confirm a code sent to their email or phone. Being logged in bypasses the two factor authentication.&#x20;

Through the add case party endpoint you can add people to a case, which will allow them to have two factor authentication codes sent to their email or phone.&#x20;

{% hint style="info" %}
If you're including email & phone in a [Start Personal Plan Request](https://docs.whiteswan.io/partner-knowledge-base/api-documentation/action-calls/start-personal-plan-request) call or a [Submit Complete Information](https://docs.whiteswan.io/partner-knowledge-base/api-documentation/action-calls/submit-complete-plan-request) Call, you do not have to add the case party through this endpoint separately. This endpoint allows you to provide several people with access to cases.
{% endhint %}

**API Method:**

## Add Case Party

<mark style="color:green;">`POST`</mark> `https://app.whiteswan.io/api/1.1/wf/invite_case_party`

Initiates an application for a particular personal plan under a plan request.

#### Headers

| Name                                            | Type   | Description            |
| ----------------------------------------------- | ------ | ---------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer \<YOUR API KEY> |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json       |
| Accept<mark style="color:red;">\*</mark>        | String | application/json       |
| user-agent<mark style="color:red;">\*</mark>    | String | \<YOUR APP>            |

#### Request Body

| Name                                        | Type   | Description             |
| ------------------------------------------- | ------ | ----------------------- |
| JSON Body<mark style="color:red;">\*</mark> | Object | See specification below |

{% tabs %}
{% tab title="200: OK Call success" %}

{% endtab %}

{% tab title="400: Bad Request Call failure" %}

{% endtab %}

{% tab title="401: Unauthorized Permission denied" %}

{% endtab %}

{% tab title="404: Not Found Not found" %}

{% endtab %}

{% tab title="405: Method Not Allowed Wrong method" %}

{% endtab %}

{% tab title="429: Too Many Requests Too many requests" %}

{% endtab %}

{% tab title="500: Internal Server Error Internal bug" %}

{% endtab %}

{% tab title="503: Service Unavailable Service unavailable" %}

{% endtab %}
{% endtabs %}

<details>

<summary>Sample Body Payload</summary>

```json
{
  "request": "1755962938878x653642511385623700",
  "invitee_email": "john@doe.com",
  "invitee_phone": "1234567892"
}
```

</details>

**Code Examples - Making the API Call:**

{% tabs %}
{% tab title="cURL" %}

```json
curl -X POST "https://app.whiteswan.io/api/1.1/wf/invite_case_party" \
     -H "Authorization: Bearer <YOUR API KEY>" \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -H "User-Agent: <YOUR APP>" \
     -d '{
               "request": "1755962938878x653642511385623700",
               "invitee_email": "john@doe.com",
               "invitee_phone": "1234567892"
          }'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://app.whiteswan.io/api/1.1/wf/invite_case_party"
headers = {
    "Authorization": "Bearer <YOUR API KEY>",
    "Content-Type": "application/json",
    "Accept": "application/json",
    "User-Agent": "<YOUR APP>"
}

data = {
    "request": "1755962938878x653642511385623700",
    "invitee_email": "john@doe.com",
    "invitee_phone": "1234567892"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
const url = "https://app.whiteswan.io/api/1.1/wf/invite_case_party";
const headers = {
    "Authorization": "Bearer <YOUR API KEY>",
    "Content-Type": "application/json",
    "Accept": "application/json",
    "user-agent": "<YOUR APP>"
};

const data = {
    request: "1755962938878x653642511385623700",
    invitee_email: "john@doe.com",
    invitee_phone: "1234567892"
};

fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
```

{% endtab %}

{% tab title="Java" %}

```java
import okhttp3.*;

public class WhiteSwanApiCall {

    public static void main(String[] args) {
        OkHttpClient client = new OkHttpClient();

        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, 
            "{ \"request\":\"1755962938878x653642511385623700\", " +
            "\"invitee_email\":\"john@doe.com\", " +
            "\"invitee_phone\":\"1234567892\" }");

        Request request = new Request.Builder()
            .url("https://app.whiteswan.io/api/1.1/wf/invite_case_party")
            .post(body)
            .addHeader("Authorization", "Bearer <YOUR API KEY>")
            .addHeader("Content-Type", "application/json")
            .addHeader("Accept", "application/json")
            .addHeader("user-agent", "<YOUR APP>")
            .build();

        try {
            Response response = client.newCall(request).execute();
            System.out.println(response.body().string());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$ch = curl_init();

$data = array(
    "request" => "1755962938878x653642511385623700",
    "invitee_email" => "john@doe.com",
    "invitee_phone" => "1234567892"
);

$headers = array(
    "Authorization: Bearer <YOUR API KEY>",
    "Content-Type: application/json",
    "Accept: application/json",
    "user-agent: <YOUR APP>"
);

curl_setopt($ch, CURLOPT_URL, "https://app.whiteswan.io/api/1.1/wf/invite_case_party");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'
require 'uri'

uri = URI.parse("https://app.whiteswan.io/api/1.1/wf/invite_case_party")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

headers = {
  'Authorization' => 'Bearer <YOUR API KEY>',
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'User-Agent' => '<YOUR APP>'
}

data = {
  request: "1755962938878x653642511385623700",
  invitee_email: "john@doe.com",
  invitee_phone: "1234567892"
}

request = Net::HTTP::Post.new(uri.path, headers)
request.body = data.to_json

response = http.request(request)
puts response.body
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"bytes"
	"fmt"
	"net/http"
)

func main() {
	url := "https://app.whiteswan.io/api/1.1/wf/invite_case_party"
	data := `{
		"request": "1755962938878x653642511385623700",
		"invitee_email": "john@doe.com",
		"invitee_phone": "1234567892"
	}`

	req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(data)))
	if err != nil {
		panic(err)
	}

	req.Header.Set("Authorization", "Bearer <YOUR API KEY>")
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Accept", "application/json")
	req.Header.Set("User-Agent", "<YOUR APP>")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	fmt.Println("Response Status:", resp.Status)
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Code examples are available in ***cURL***, ***Python***, ***Javascript***, ***Java***, ***PHP***, ***Ruby***, and ***Go***, but can be constructed for other languages and tools. Some code examples include dependencies that may need to be installed in your codebase to ensure functionality. Remember to replace any values in the code that looks like \<VALUE> and to adapt the parameter values passed.
{% endhint %}

***

**Body Parameters Specification:**

<table data-full-width="true"><thead><tr><th>Field Label</th><th>Field Key</th><th data-type="checkbox">Required?</th><th>Field Type</th><th>Example Value</th><th>Description</th></tr></thead><tbody><tr><td>Linked Plan Request</td><td>request</td><td>true</td><td>Text</td><td>1755962938878x653642511385623700</td><td>The ID of the plan request that you want to add this case part to.</td></tr><tr><td>Email Address</td><td>invitee_email</td><td>false</td><td>Text</td><td>john@doe.com</td><td>The email of the case party that you want to add to this case.</td></tr><tr><td>Phone Number</td><td>invitee_phone</td><td>false</td><td>Text</td><td>1234567892</td><td>The phone number of the case party that you want to add to this case.</td></tr></tbody></table>

***

<details>

<summary>Sample Return Payload</summary>

```json
{
    "status": "Success",
    "request": "1755719935099x532381077173698560",
    "request_parties": [
        {
            "email": "john@doe.com",
            "phone": "1234567890",
            "party_id": "1756137602217x954719111964025200"
        }
    ],
    "error_message":null
}
```

</details>

**Returned Parameters Specification:**

<table data-full-width="true"><thead><tr><th>Field Label</th><th>Field Key</th><th>Field Type</th><th>Example Value</th><th>Description</th><th>Alternatives (if Multiple-Choice)</th></tr></thead><tbody><tr><td>Status</td><td>status</td><td>Multiple-choice</td><td>Success</td><td>Whether the request was succesful.</td><td>Success, Failure</td></tr><tr><td>Linked Plan Request</td><td>request</td><td>Text</td><td>1755962937306x171818994560791740</td><td>The ID of the plan request associated with the call.</td><td>-</td></tr><tr><td>Request Parties</td><td>request_parties</td><td>Object List</td><td>-</td><td>A list of the current case parties associated with this case.</td><td>-</td></tr><tr><td><ul><li>Email</li></ul></td><td>email</td><td>Text</td><td>john@doe.com</td><td>The email of this case access party.</td><td>-</td></tr><tr><td><ul><li>Phone</li></ul></td><td>phone</td><td>Text</td><td>1234567890</td><td>The phone number of this case access party.</td><td>-</td></tr><tr><td><ul><li>Party ID</li></ul></td><td>party_id</td><td>Text</td><td>1755962937306x171818994560791740</td><td>The ID of this case access party.</td><td>-</td></tr><tr><td>Error Message</td><td>error_message</td><td>Text</td><td>We could not find a plan request with this ID or verify that your call contained a phone number/email. Try to double-check the email/phone and/or map an ID returned from another action/trigger.</td><td>If the call fails this parameter will provide details on the error.</td><td>-</td></tr></tbody></table>
