# Generate connection strings

> Generate connection strings: TrueProxies customer API reference with the required scope, parameters, responses and code samples.

Source: https://docs.trueproxies.com/api/operations/post_v1_services_id_endpoints/

`POST /v1/services/{id}/endpoints`

**Fetch**

```js
const url = 'https://api.trueproxies.com/v1/services/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/endpoints';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"asn":"example","city":"example","count":1,"country":"example","format":"host:port:user:pass","job_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","lifetime":1,"project_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","protocol":"http","region":"example","session":"none","template":"example"}'
};

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

**cURL**

```sh
curl --request POST \
  --url https://api.trueproxies.com/v1/services/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/endpoints \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{ "asn": "example", "city": "example", "count": 1, "country": "example", "format": "host:port:user:pass", "job_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "lifetime": 1, "project_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "protocol": "http", "region": "example", "session": "none", "template": "example" }'
```

Builds connection strings without changing the service. Only use targeting and session options present in the service capabilities. Copy the returned line into your proxy client; credentials in the output are secret.

## Authorizations

- **[customerAPIKey](https://docs.trueproxies.com/api/#customerapikey)**

## Parameters

### Path Parameters

- **id**

  required

  string format: uuid

### Query Parameters

- **customer\_id**

  string format: uuid

  Owned sub-customer UUID. Resellers only; reads require reseller:read and writes reseller:purchase in addition to the operation scope. X-Customer-Id header is an alternative. Not allowed for me, wallet, trial, API keys, or reseller-management routes.

## Request Body (required)

Media type: `application/json`

object

- **asn**

  1 to 10 digits, without AS prefix. Requires asn capability.

  string

  <= 10 characters

- **city**

  Letters, digits and underscores; normalized to lowercase. Requires city capability.

  string

  <= 32 characters

- **count**

  Number of connection strings. Omission, null and legacy zero values use one.

  integer

  default: 1 >= 1 <= 1000

- **country**

  Two-letter country code; normalized to lowercase. Requires country capability.

  string

- **format**

  string

  default: host:port:user:pass

  Allowed values: host:port:user:pass user:pass\@host:port user:pass host:port url curl custom

- **job\_id**

  Owned active job beneath project\_id. Only its validated opaque token is included in generated proxy usernames.

  string format: uuid

- **lifetime**

  Sticky session lifetime in seconds, 60 to 86400, or 1 to 86400 when the service has session\_lifetime\_seconds. Maximum is 1800 with session\_lifetime\_30m. Requires session=sticky and session\_lifetime capability. Residential IPv4 Unlimited requires whole minutes. Omitted or zero leaves the lifetime unset.

  integer

- **project\_id**

  Owned, active project access. Omit to use main access. Requires current project support.

  string format: uuid

- **protocol**

  string

  default: http

  Allowed values: http socks5 https

- **region**

  Requires region capability. Services with region\_code accept only an ISO 3166-2 subdivision code of 1 to 3 letters or digits without country prefix (for example CA). Other services accept letters, digits and underscores up to 32 characters. Normalized to lowercase in customer usernames.

  string

  <= 32 characters

- **session**

  string

  default: none

  Allowed values: none sticky rotate

- **template**

  Required only for format=custom. A single line of literal text, limited to 512 UTF-8 bytes, with at least one of {HOST}, {PORT}, {USER}, {PASS} or {PROTOCOL}. Other braces and control characters are rejected. Placeholder values are substituted literally without escaping or recursive expansion. {PROTOCOL} is the connection URL scheme (http, https or socks5h).

  string

  \>= 1 characters <= 512 characters

## Responses

### 200

Ok

Media type: `application/json`

object

- **lines**

  required

  Array\<string>

##### Example (generated)

```json
{
  "lines": [
    "example"
  ]
}
```

### 400

Error

Media type: `application/json`

object

- **code**

  required

  string

  Allowed values: BAD\_REQUEST UNAUTHENTICATED FORBIDDEN NOT\_FOUND CONFLICT RATE\_LIMITED SERVICE\_UNAVAILABLE OFFER\_UNAVAILABLE CITY\_UNAVAILABLE CAPACITY\_UNAVAILABLE INVOICE\_NOT\_PAYABLE PROVIDER\_ERROR PIPE\_UNAVAILABLE TRIAL\_NOT\_ELIGIBLE EMAIL\_UNVERIFIED INTERNAL

- **details**

  What a client needs to act on the error (ids, flags), never display text.

  object

  - ***key***

    additional properties

    any

- **message**

  required

  string

##### Example

```json
{
  "code": "BAD_REQUEST"
}
```

### 401

Error

Media type: `application/json`

object

- **code**

  required

  string

  Allowed values: BAD\_REQUEST UNAUTHENTICATED FORBIDDEN NOT\_FOUND CONFLICT RATE\_LIMITED SERVICE\_UNAVAILABLE OFFER\_UNAVAILABLE CITY\_UNAVAILABLE CAPACITY\_UNAVAILABLE INVOICE\_NOT\_PAYABLE PROVIDER\_ERROR PIPE\_UNAVAILABLE TRIAL\_NOT\_ELIGIBLE EMAIL\_UNVERIFIED INTERNAL

- **details**

  What a client needs to act on the error (ids, flags), never display text.

  object

  - ***key***

    additional properties

    any

- **message**

  required

  string

##### Example

```json
{
  "code": "BAD_REQUEST"
}
```

### 403

Error

Media type: `application/json`

object

- **code**

  required

  string

  Allowed values: BAD\_REQUEST UNAUTHENTICATED FORBIDDEN NOT\_FOUND CONFLICT RATE\_LIMITED SERVICE\_UNAVAILABLE OFFER\_UNAVAILABLE CITY\_UNAVAILABLE CAPACITY\_UNAVAILABLE INVOICE\_NOT\_PAYABLE PROVIDER\_ERROR PIPE\_UNAVAILABLE TRIAL\_NOT\_ELIGIBLE EMAIL\_UNVERIFIED INTERNAL

- **details**

  What a client needs to act on the error (ids, flags), never display text.

  object

  - ***key***

    additional properties

    any

- **message**

  required

  string

##### Example

```json
{
  "code": "BAD_REQUEST"
}
```

### 404

Error

Media type: `application/json`

object

- **code**

  required

  string

  Allowed values: BAD\_REQUEST UNAUTHENTICATED FORBIDDEN NOT\_FOUND CONFLICT RATE\_LIMITED SERVICE\_UNAVAILABLE OFFER\_UNAVAILABLE CITY\_UNAVAILABLE CAPACITY\_UNAVAILABLE INVOICE\_NOT\_PAYABLE PROVIDER\_ERROR PIPE\_UNAVAILABLE TRIAL\_NOT\_ELIGIBLE EMAIL\_UNVERIFIED INTERNAL

- **details**

  What a client needs to act on the error (ids, flags), never display text.

  object

  - ***key***

    additional properties

    any

- **message**

  required

  string

##### Example

```json
{
  "code": "BAD_REQUEST"
}
```

### 409

Error

Media type: `application/json`

object

- **code**

  required

  string

  Allowed values: BAD\_REQUEST UNAUTHENTICATED FORBIDDEN NOT\_FOUND CONFLICT RATE\_LIMITED SERVICE\_UNAVAILABLE OFFER\_UNAVAILABLE CITY\_UNAVAILABLE CAPACITY\_UNAVAILABLE INVOICE\_NOT\_PAYABLE PROVIDER\_ERROR PIPE\_UNAVAILABLE TRIAL\_NOT\_ELIGIBLE EMAIL\_UNVERIFIED INTERNAL

- **details**

  What a client needs to act on the error (ids, flags), never display text.

  object

  - ***key***

    additional properties

    any

- **message**

  required

  string

##### Example

```json
{
  "code": "BAD_REQUEST"
}
```

### 429

Error

Media type: `application/json`

object

- **code**

  required

  string

  Allowed values: BAD\_REQUEST UNAUTHENTICATED FORBIDDEN NOT\_FOUND CONFLICT RATE\_LIMITED SERVICE\_UNAVAILABLE OFFER\_UNAVAILABLE CITY\_UNAVAILABLE CAPACITY\_UNAVAILABLE INVOICE\_NOT\_PAYABLE PROVIDER\_ERROR PIPE\_UNAVAILABLE TRIAL\_NOT\_ELIGIBLE EMAIL\_UNVERIFIED INTERNAL

- **details**

  What a client needs to act on the error (ids, flags), never display text.

  object

  - ***key***

    additional properties

    any

- **message**

  required

  string

##### Example

```json
{
  "code": "BAD_REQUEST"
}
```

### 500

Error

Media type: `application/json`

object

- **code**

  required

  string

  Allowed values: BAD\_REQUEST UNAUTHENTICATED FORBIDDEN NOT\_FOUND CONFLICT RATE\_LIMITED SERVICE\_UNAVAILABLE OFFER\_UNAVAILABLE CITY\_UNAVAILABLE CAPACITY\_UNAVAILABLE INVOICE\_NOT\_PAYABLE PROVIDER\_ERROR PIPE\_UNAVAILABLE TRIAL\_NOT\_ELIGIBLE EMAIL\_UNVERIFIED INTERNAL

- **details**

  What a client needs to act on the error (ids, flags), never display text.

  object

  - ***key***

    additional properties

    any

- **message**

  required

  string

##### Example

```json
{
  "code": "BAD_REQUEST"
}
```

### 503

Error

Media type: `application/json`

object

- **code**

  required

  string

  Allowed values: BAD\_REQUEST UNAUTHENTICATED FORBIDDEN NOT\_FOUND CONFLICT RATE\_LIMITED SERVICE\_UNAVAILABLE OFFER\_UNAVAILABLE CITY\_UNAVAILABLE CAPACITY\_UNAVAILABLE INVOICE\_NOT\_PAYABLE PROVIDER\_ERROR PIPE\_UNAVAILABLE TRIAL\_NOT\_ELIGIBLE EMAIL\_UNVERIFIED INTERNAL

- **details**

  What a client needs to act on the error (ids, flags), never display text.

  object

  - ***key***

    additional properties

    any

- **message**

  required

  string

##### Example

```json
{
  "code": "BAD_REQUEST"
}
```
