RequestRocket Documentation
API ReferenceCore API

Targets API

Configure target API endpoints programmatically

Targets API

Configure target API endpoints that your proxies will connect to. Targets define the base URL and test path for third-party APIs.

Targets are stored regionally for data sovereignty. Once created, the region cannot be changed.

Endpoints

MethodEndpointDescription
GET/api/clients/{clientId}/targetsList all targets
POST/api/clients/{clientId}/targetsCreate a target
GET/api/clients/{clientId}/targets/{targetId}Get target details
PUT/api/clients/{clientId}/targets/{targetId}Update target
DELETE/api/clients/{clientId}/targets/{targetId}Delete target

List Targets

Get all targets for a client.

Request

GET /api/clients/{clientId}/targets HTTP/1.1
Host: api.requestrocket.com
Authorization: {user_token}

Response

{
  "targets": [
    {
      "pKey": "550e8400-e29b-41d4-a716-446655440000",
      "sKey": "tgt_789e4567",
      "targetName": "Stripe API",
      "targetBaseURL": "https://api.stripe.com",
      "targetTestPath": "/v1/customers",
      "targetRegion": "us-east-1",
      "targetDefaultRuleEffect": "allow",
      "userId": "123e4567-e89b-12d3-a456-426614174000",
      "clientId": "550e8400-e29b-41d4-a716-446655440000",
      "parentId": "550e8400-e29b-41d4-a716-446655440000",
      "targetCreatedAt": "2024-01-22T12:00:00.000Z",
      "targetUpdatedAt": "2024-01-22T12:00:00.000Z"
    }
  ],
  "message": "Success"
}

Example

const response = await fetch(
  `https://api.requestrocket.com/api/clients/${clientId}/targets`,
  {
    headers: {
      'Authorization': process.env.USER_TOKEN
    }
  }
);

const data = await response.json();
console.log('Targets:', data.targets);
import requests
import os

client_id = "your-client-id"

response = requests.get(
    f'https://api.requestrocket.com/api/clients/{client_id}/targets',
    headers={'Authorization': os.getenv('USER_TOKEN')}
)

data = response.json()
print(f"Found {len(data['targets'])} targets")
package main

import (
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "os"
)

type Response struct {
    Targets []map[string]interface{} `json:"targets"`
    Message string                   `json:"message"`
}

func main() {
    clientId := "your-client-id"
    url := fmt.Sprintf("https://api.requestrocket.com/api/clients/%s/targets", clientId)
    
    req, _ := http.NewRequest("GET", url, nil)
    req.Header.Set("Authorization", os.Getenv("USER_TOKEN"))

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    var result Response
    json.Unmarshal(body, &result)
    
    fmt.Printf("Found %d targets\n", len(result.Targets))
}
import java.net.http.*;
import java.net.URI;
import com.google.gson.*;

public class ListTargets {
    public static void main(String[] args) throws Exception {
        String clientId = "your-client-id";
        
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.requestrocket.com/api/clients/" + clientId + "/targets"))
            .header("Authorization", System.getenv("USER_TOKEN"))
            .GET()
            .build();

        HttpResponse<String> response = client.send(request, 
            HttpResponse.BodyHandlers.ofString());

        JsonObject json = JsonParser.parseString(response.body()).getAsJsonObject();
        JsonArray targets = json.getAsJsonArray("targets");
        System.out.println("Found " + targets.size() + " targets");
    }
}
curl -X GET "https://api.requestrocket.com/api/clients/${CLIENT_ID}/targets" \
  -H "Authorization: ${USER_TOKEN}"

Create Target

Create a new target configuration.

Request

POST /api/clients/{clientId}/targets HTTP/1.1
Host: api.requestrocket.com
Authorization: {user_token}
Content-Type: application/json

{
  "targetName": "Stripe API",
  "targetRegion": "us-east-1",
  "targetBaseURL": "https://api.stripe.com",
  "targetTestPath": "/v1/customers",
  "targetDefaultRuleEffect": "allow"
}

Request Body

FieldTypeRequiredDescription
targetNamestringYesDescriptive name for the target
targetRegionstringYesAWS region for data storage
targetBaseURLstringYesBase URL of the target API
targetTestPathstringYesHealth check endpoint path (relative to base URL)
targetDefaultRuleEffectstringNoDefault authorization effect: allow or deny (default: allow)

The targetRegion cannot be changed after creation. Targets must be in the same region as their associated credentials and proxies.

Response

{
  "targets": [
    {
      "targetName": "Stripe API",
      "targetBaseURL": "https://api.stripe.com",
      "targetTestPath": "/v1/customers",
      "targetRegion": "us-east-1",
      "targetDefaultRuleEffect": "allow",
      "clientId": "550e8400-e29b-41d4-a716-446655440000",
      "userId": "123e4567-e89b-12d3-a456-426614174000",
      "parentId": "550e8400-e29b-41d4-a716-446655440000",
      "targetCreatedAt": "2024-01-22T12:00:00.000Z",
      "targetUpdatedAt": "2024-01-22T12:00:00.000Z"
    }
  ],
  "message": "Target created successfully"
}

Example

const response = await fetch(
  `https://api.requestrocket.com/api/clients/${clientId}/targets`,
  {
    method: 'POST',
    headers: {
      'Authorization': process.env.USER_TOKEN,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      targetName: 'Stripe API',
      targetRegion: 'us-east-1',
      targetBaseURL: 'https://api.stripe.com',
      targetTestPath: '/v1/customers',
      targetDefaultRuleEffect: 'allow'
    })
  }
);

const data = await response.json();
console.log('Created target:', data.targets[0]);
import requests
import os

response = requests.post(
    f'https://api.requestrocket.com/api/clients/{client_id}/targets',
    headers={'Authorization': os.getenv('USER_TOKEN')},
    json={
        'targetName': 'Stripe API',
        'targetRegion': 'us-east-1',
        'targetBaseURL': 'https://api.stripe.com',
        'targetTestPath': '/v1/customers',
        'targetDefaultRuleEffect': 'allow'
    }
)

data = response.json()
print(f"Created target: {data['targets'][0]['targetName']}")
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "os"
)

type CreateTargetRequest struct {
    TargetName               string `json:"targetName"`
    TargetRegion            string `json:"targetRegion"`
    TargetBaseURL           string `json:"targetBaseURL"`
    TargetTestPath          string `json:"targetTestPath"`
    TargetDefaultRuleEffect string `json:"targetDefaultRuleEffect"`
}

type Response struct {
    Targets []map[string]interface{} `json:"targets"`
    Message string                   `json:"message"`
}

func main() {
    clientId := "your-client-id"
    requestBody, _ := json.Marshal(CreateTargetRequest{
        TargetName:               "Stripe API",
        TargetRegion:            "us-east-1",
        TargetBaseURL:           "https://api.stripe.com",
        TargetTestPath:          "/v1/customers",
        TargetDefaultRuleEffect: "allow",
    })

    url := fmt.Sprintf("https://api.requestrocket.com/api/clients/%s/targets", clientId)
    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
    req.Header.Set("Authorization", os.Getenv("USER_TOKEN"))
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    var result Response
    json.Unmarshal(body, &result)
    
    fmt.Printf("Created target: %v\n", result.Targets[0]["targetName"])
}
import java.net.http.*;
import java.net.URI;
import com.google.gson.*;

public class CreateTarget {
    public static void main(String[] args) throws Exception {
        String clientId = "your-client-id";
        String json = "{"
            + "\"targetName\": \"Stripe API\","
            + "\"targetRegion\": \"us-east-1\","
            + "\"targetBaseURL\": \"https://api.stripe.com\","
            + "\"targetTestPath\": \"/v1/customers\","
            + "\"targetDefaultRuleEffect\": \"allow\""
            + "}";
        
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.requestrocket.com/api/clients/" + clientId + "/targets"))
            .header("Authorization", System.getenv("USER_TOKEN"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .build();

        HttpResponse<String> response = client.send(request, 
            HttpResponse.BodyHandlers.ofString());

        JsonObject jsonResponse = JsonParser.parseString(response.body()).getAsJsonObject();
        JsonArray targets = jsonResponse.getAsJsonArray("targets");
        JsonObject newTarget = targets.get(0).getAsJsonObject();
        System.out.println("Created target: " + newTarget.get("targetName").getAsString());
    }
}
curl -X POST "https://api.requestrocket.com/api/clients/${CLIENT_ID}/targets" \
  -H "Authorization: ${USER_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "targetName": "Stripe API",
    "targetRegion": "us-east-1",
    "targetBaseURL": "https://api.stripe.com",
    "targetTestPath": "/v1/customers",
    "targetDefaultRuleEffect": "allow"
  }'

Get Target

Get details of a specific target.

Request

GET /api/clients/{clientId}/targets/{targetId} HTTP/1.1
Host: api.requestrocket.com
Authorization: {user_token}

Response

{
  "targets": [
    {
      "pKey": "550e8400-e29b-41d4-a716-446655440000",
      "sKey": "tgt_789e4567",
      "targetName": "Stripe API",
      "targetBaseURL": "https://api.stripe.com",
      "targetTestPath": "/v1/customers",
      "targetRegion": "us-east-1",
      "targetDefaultRuleEffect": "allow",
      "userId": "123e4567-e89b-12d3-a456-426614174000",
      "clientId": "550e8400-e29b-41d4-a716-446655440000",
      "parentId": "550e8400-e29b-41d4-a716-446655440000",
      "targetCreatedAt": "2024-01-22T12:00:00.000Z",
      "targetUpdatedAt": "2024-01-22T12:00:00.000Z"
    }
  ],
  "message": "Success"
}

Example

const response = await fetch(
  `https://api.requestrocket.com/api/clients/${clientId}/targets/${targetId}`,
  {
    headers: {
      'Authorization': process.env.USER_TOKEN
    }
  }
);

const data = await response.json();
console.log('Target:', data.targets[0]);
import requests
import os

client_id = "your-client-id"
target_id = "your-target-id"

response = requests.get(
    f'https://api.requestrocket.com/api/clients/{client_id}/targets/{target_id}',
    headers={'Authorization': os.getenv('USER_TOKEN')}
)

data = response.json()
print(f"Target: {data['targets'][0]['targetName']}")
package main

import (
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "os"
)

type Response struct {
    Targets []map[string]interface{} `json:"targets"`
    Message string                   `json:"message"`
}

func main() {
    clientId := "your-client-id"
    targetId := "your-target-id"
    url := fmt.Sprintf("https://api.requestrocket.com/api/clients/%s/targets/%s", clientId, targetId)
    
    req, _ := http.NewRequest("GET", url, nil)
    req.Header.Set("Authorization", os.Getenv("USER_TOKEN"))

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    var result Response
    json.Unmarshal(body, &result)
    
    fmt.Printf("Target: %v\n", result.Targets[0])
}
import java.net.http.*;
import java.net.URI;
import com.google.gson.*;

public class GetTarget {
    public static void main(String[] args) throws Exception {
        String clientId = "your-client-id";
        String targetId = "your-target-id";
        
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.requestrocket.com/api/clients/" + clientId + "/targets/" + targetId))
            .header("Authorization", System.getenv("USER_TOKEN"))
            .GET()
            .build();

        HttpResponse<String> response = client.send(request, 
            HttpResponse.BodyHandlers.ofString());

        JsonObject json = JsonParser.parseString(response.body()).getAsJsonObject();
        JsonArray targets = json.getAsJsonArray("targets");
        System.out.println("Target: " + targets.get(0));
    }
}
curl -X GET "https://api.requestrocket.com/api/clients/${CLIENT_ID}/targets/${TARGET_ID}" \
  -H "Authorization: ${USER_TOKEN}"

Update Target

Update an existing target's configuration. The region cannot be changed.

Request

PUT /api/clients/{clientId}/targets/{targetId} HTTP/1.1
Host: api.requestrocket.com
Authorization: {user_token}
Content-Type: application/json

{
  "targetName": "Stripe API (Updated)",
  "targetBaseURL": "https://api.stripe.com/v2",
  "targetTestPath": "/v2/health",
  "targetDefaultRuleEffect": "deny"
}

Request Body

FieldTypeRequiredDescription
targetNamestringNoUpdated name for the target
targetBaseURLstringNoUpdated base URL
targetTestPathstringNoUpdated test path
targetDefaultRuleEffectstringNoUpdated default rule effect

Only provided fields will be updated. Omitted fields retain their current values.

Response

{
  "targets": [
    {
      "targetName": "Stripe API (Updated)",
      "targetBaseURL": "https://api.stripe.com/v2",
      "targetTestPath": "/v2/health",
      "targetRegion": "us-east-1",
      "targetDefaultRuleEffect": "deny",
      "clientId": "550e8400-e29b-41d4-a716-446655440000",
      "userId": "123e4567-e89b-12d3-a456-426614174000",
      "parentId": "550e8400-e29b-41d4-a716-446655440000",
      "targetCreatedAt": "2024-01-22T12:00:00.000Z",
      "targetUpdatedAt": "2024-01-23T10:30:00.000Z"
    }
  ],
  "message": "Target updated successfully"
}

Example

const response = await fetch(
  `https://api.requestrocket.com/api/clients/${clientId}/targets/${targetId}`,
  {
    method: 'PUT',
    headers: {
      'Authorization': process.env.USER_TOKEN,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      targetName: 'Stripe API (Updated)',
      targetBaseURL: 'https://api.stripe.com/v2'
    })
  }
);

const data = await response.json();
console.log('Updated target:', data.targets[0]);
import requests
import os

client_id = "your-client-id"
target_id = "your-target-id"

response = requests.put(
    f'https://api.requestrocket.com/api/clients/{client_id}/targets/{target_id}',
    headers={'Authorization': os.getenv('USER_TOKEN')},
    json={
        'targetName': 'Stripe API (Updated)',
        'targetBaseURL': 'https://api.stripe.com/v2'
    }
)

data = response.json()
print(f"Updated: {data['message']}")
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "os"
)

type UpdateTargetRequest struct {
    TargetName    string `json:"targetName"`
    TargetBaseURL string `json:"targetBaseURL"`
}

func main() {
    clientId := "your-client-id"
    targetId := "your-target-id"

    requestBody, _ := json.Marshal(UpdateTargetRequest{
        TargetName:    "Stripe API (Updated)",
        TargetBaseURL: "https://api.stripe.com/v2",
    })

    url := fmt.Sprintf("https://api.requestrocket.com/api/clients/%s/targets/%s", clientId, targetId)
    req, _ := http.NewRequest("PUT", url, bytes.NewBuffer(requestBody))
    req.Header.Set("Authorization", os.Getenv("USER_TOKEN"))
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
import java.net.http.*;
import java.net.URI;
import com.google.gson.*;

public class UpdateTarget {
    public static void main(String[] args) throws Exception {
        String clientId = "your-client-id";
        String targetId = "your-target-id";
        String json = "{"
            + "\"targetName\": \"Stripe API (Updated)\","
            + "\"targetBaseURL\": \"https://api.stripe.com/v2\""
            + "}";

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.requestrocket.com/api/clients/" + clientId + "/targets/" + targetId))
            .header("Authorization", System.getenv("USER_TOKEN"))
            .header("Content-Type", "application/json")
            .PUT(HttpRequest.BodyPublishers.ofString(json))
            .build();

        HttpResponse<String> response = client.send(request,
            HttpResponse.BodyHandlers.ofString());

        System.out.println(response.body());
    }
}
curl -X PUT "https://api.requestrocket.com/api/clients/${CLIENT_ID}/targets/${TARGET_ID}" \
  -H "Authorization: ${USER_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "targetName": "Stripe API (Updated)",
    "targetBaseURL": "https://api.stripe.com/v2"
  }'

Delete Target

Delete a target and all associated proxy configurations.

Deleting a target will also delete all proxies that use this target. This action cannot be undone.

Request

DELETE /api/clients/{clientId}/targets/{targetId} HTTP/1.1
Host: api.requestrocket.com
Authorization: {user_token}

Response

{
  "message": "Target deleted successfully"
}

Example

const response = await fetch(
  `https://api.requestrocket.com/api/clients/${clientId}/targets/${targetId}`,
  {
    method: 'DELETE',
    headers: {
      'Authorization': process.env.USER_TOKEN
    }
  }
);

const data = await response.json();
console.log(data.message);
import requests
import os

client_id = "your-client-id"
target_id = "your-target-id"

response = requests.delete(
    f'https://api.requestrocket.com/api/clients/{client_id}/targets/{target_id}',
    headers={'Authorization': os.getenv('USER_TOKEN')}
)

data = response.json()
print(data['message'])
package main

import (
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "os"
)

type Response struct {
    Message string `json:"message"`
}

func main() {
    clientId := "your-client-id"
    targetId := "your-target-id"
    
    url := fmt.Sprintf("https://api.requestrocket.com/api/clients/%s/targets/%s", clientId, targetId)
    req, _ := http.NewRequest("DELETE", url, nil)
    req.Header.Set("Authorization", os.Getenv("USER_TOKEN"))

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    var result Response
    json.Unmarshal(body, &result)
    
    fmt.Println(result.Message)
}
import java.net.http.*;
import java.net.URI;
import com.google.gson.*;

public class DeleteTarget {
    public static void main(String[] args) throws Exception {
        String clientId = "your-client-id";
        String targetId = "your-target-id";
        
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.requestrocket.com/api/clients/" + clientId + "/targets/" + targetId))
            .header("Authorization", System.getenv("USER_TOKEN"))
            .DELETE()
            .build();

        HttpResponse<String> response = client.send(request, 
            HttpResponse.BodyHandlers.ofString());

        JsonObject json = JsonParser.parseString(response.body()).getAsJsonObject();
        System.out.println(json.get("message").getAsString());
    }
}
curl -X DELETE "https://api.requestrocket.com/api/clients/${CLIENT_ID}/targets/${TARGET_ID}" \
  -H "Authorization: ${USER_TOKEN}"

Next Steps

On this page