> Use the canonical URL for citations. For the complete Predict API documentation index, fetch https://docs.staging.trypredict.com/llms.txt.

# Split a position

POST https://api.staging.trypredict.com/v1/trading/positions/split
Content-Type: application/json

Split collateral into both sides of an outcome. action.type must be
 "userOutcome" carrying splitOutcome.

Reference: https://docs.staging.trypredict.com/api-reference/trading/trading-service-split-position

## Response

### 200

OK

## Errors

### 400 Bad Request Error

The request is malformed or violates a field constraint.

- `error` (RESTError, required)

### 405 Method Not Allowed Error

The HTTP method is not allowed on this path.

- `error` (RESTError, required)

### 429 Too Many Requests Error

The endpoint or combined rolling request quota is exhausted.

- `error` (RESTError, required)

### 500 Internal Server Error

The server could not complete the request.

- `error` (RESTError, required)

### 503 Service Unavailable Error

A required dependency is temporarily unavailable.

- `error` (RESTError, required)

## Types

### RESTError

- `code` (integer, required) — HTTP status code returned with the response.
- `status` (enum, required) — Stable canonical status name suitable for programmatic handling.
  - Allowed values: `INVALID_ARGUMENT`, `UNAUTHENTICATED`, `PERMISSION_DENIED`, `NOT_FOUND`, `METHOD_NOT_ALLOWED`, `ALREADY_EXISTS`, `RESOURCE_EXHAUSTED`, `INTERNAL`, `UNAVAILABLE`, `DEADLINE_EXCEEDED`
- `message` (string, required) — Human-readable explanation that is safe to show to an API caller.
- `details` (list of ErrorDetail, required) — Typed structured context for clients that need to handle the error programmatically.

### ErrorDetail

- `type`: `field_violation` (field_violation)
  - `field` (string, required) — Request field that failed validation.
  - `reason` (string, required) — Stable machine-readable reason for the validation failure.
- `type`: `rate_limit` (rate_limit)
  - `limit` (long, required) — Maximum requests allowed during the rolling window.
  - `reason` (string, required) — Stable machine-readable reason identifying the exhausted policy.
  - `retry_after_seconds` (long, required) — Whole seconds until the exhausted policy has capacity.
  - `scope` (enum, required) — Quota that rejected the request.
    - Allowed values: `endpoint`, `global`
  - `window_seconds` (long, required) — Rolling-window duration in seconds.
- `type`: `dependency` (dependency)
  - `reason` (string, required) — Stable machine-readable reason for the temporary dependency failure.

## Examples

**Request**

```json
{}
```

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://api.staging.trypredict.com/v1/trading/positions/split"

payload = {}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.staging.trypredict.com/v1/trading/positions/split';
const options = {method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{}'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staging.trypredict.com/v1/trading/positions/split"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

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

url = URI("https://api.staging.trypredict.com/v1/trading/positions/split")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{}"

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.staging.trypredict.com/v1/trading/positions/split")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staging.trypredict.com/v1/trading/positions/split', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.staging.trypredict.com/v1/trading/positions/split");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staging.trypredict.com/v1/trading/positions/split")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```