Skip to main content
POST
/
cloud
/
v1
/
l7policies
/
{project_id}
/
{region_id}
Python
import os
from gcore import Gcore

client = Gcore(
    api_key=os.environ.get("GCORE_API_KEY"),  # This is the default and can be omitted
)
task_id_list = client.cloud.load_balancers.l7_policies.create(
    project_id=1,
    region_id=1,
    action="REDIRECT_TO_URL",
    listener_id="023f2e34-7806-443b-bfae-16c324569a3d",
    redirect_url="https://www.example.com",
)
print(task_id_list.tasks)
{
  "tasks": [
    "<string>"
  ]
}

Authorizations

Authorization
string
header
required

API key for authentication. Make sure to include the word apikey, followed by a single space and then your token. Example: apikey 1234$abcdef

Path Parameters

project_id
integer
required

Project ID

region_id
integer
required

Region ID

Body

application/json
  • CreateL7PolicyRedirectToUrlSerializer
  • CreateL7PolicyRedirectPrefixSerializer
  • CreateL7PolicyRedirectToPoolSerializer
  • CreateL7PolicyRejectSerializer
action
string
required

Action

Allowed value: "REDIRECT_TO_URL"
listener_id
string
required

Listener ID

redirect_url
string
required

Requests matching this policy will be redirected to this URL.

name
string

Human-readable name of the policy

position
integer

The position of this policy on the listener

redirect_http_code
integer
default:302

Requests matching this policy will be redirected to the specified URL or Prefix URL with the HTTP response code. Valid options are 301, 302, 303, 307, or 308. Default is 302.

tags
string[]

A list of simple strings assigned to the resource.

Response

200 - application/json

OK

tasks
string[]
required

List of task IDs representing asynchronous operations. Use these IDs to monitor operation progress:

  • GET /v1/tasks/{task_id} - Check individual task status and details Poll task status until completion (FINISHED/ERROR) before proceeding with dependent operations.