Generate and apply Kasada headers with Go

By solvethree3 min read

Create a KasadaTask, then send the complete returned header set and browser identity through the successful proxy. The official Go SDK generates the solution; your net/http client makes the target request. No local browser or plugin is needed.

On this page

Configure and run the Go example

Use Go 1.22 or later and install the official module at solvethree.com/[email protected]. The Go integration documentation covers installation.

Standalone Kasada currently supports HTTPS targets on the exact hostname www.ticketmaster.com. The example requests its homepage; change input.URL to the intended URL on that supported host.

  • Set SOLVETHREE_API_KEY to your workspace API key. Keep it on the server.
  • Set SOLVETHREE_PROXY to an HTTP or HTTPS proxy URL without a path, query or fragment. This example uses one proxy; don't also supply ProxyCandidates.
  • Keep Type set to KasadaTask. Don't add Site, Action, RecaptchaType, session or custom browser identity fields.
Go · apply the complete Kasada header set
package main

import (
    "context"
    "fmt"
    "log"
    "os"
    "net/http"
    "net/url"
    "time"
    solvethree "solvethree.com/sdk"
)

func main() {
    client, err := solvethree.NewClient(os.Getenv("SOLVETHREE_API_KEY"), nil)
    if err != nil { log.Fatal(err) }
    ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second)
    defer cancel()
    input := solvethree.TaskRequest{Type: "KasadaTask", URL: "https://www.ticketmaster.com/", Proxy: os.Getenv("SOLVETHREE_PROXY")}
    result, err := client.Solve(ctx, input, solvethree.SolveOptions{})
    if err != nil { log.Fatal(err) }
    fmt.Println("Ready task:", result.ID)

    proxy, ok := solvethree.SuccessfulProxy(input, result)
    if !ok { log.Fatal("No valid successful proxy") }
    proxyURL, err := url.Parse(proxy)
    if err != nil { log.Fatal(err) }
    transport := http.DefaultTransport.(*http.Transport).Clone()
    transport.Proxy = http.ProxyURL(proxyURL)
    defer transport.CloseIdleConnections()
    targetClient := &http.Client{Transport: transport, Timeout: 30*time.Second,
        CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
    request, err := http.NewRequestWithContext(ctx, "GET", input.URL, nil)
    if err != nil { log.Fatal(err) }

    request.Header.Set("User-Agent", result.Solution.UserAgent)
    request.Header.Set("sec-ch-ua", result.Solution.SecChUA)
    for name, value := range result.Solution.Headers { request.Header.Set(name, value) }

    response, err := targetClient.Do(request)
    if err != nil { log.Fatal(err) }
    defer response.Body.Close()
    fmt.Println("Application HTTP status:", response.StatusCode)
    // Inspect the application response to determine whether submission succeeded.

}

Keep the headers, browser identity and proxy together

For Kasada, apply result.Solution.Headers, not Solution.Token. The loop copies every returned header. The preceding assignments also apply the returned UserAgent and SecChUA; don't replace them with values from your own browser.

SuccessfulProxy(input, result) identifies the successful proxy, and http.ProxyURL routes the target request through it. Use that result rather than choosing another proxy at submission time. This also matters if you later switch the task to proxy candidates.

The target request uses input.URL, so solving and submission address the same URL. Redirect following is disabled: the client returns the redirect response instead of automatically sending the generated headers to another URL.

Check the application response before calling it successful

“Ready task” means a solution was generated, not that Ticketmaster accepted it. The example prints the application HTTP status but leaves response interpretation to you. Inspect the response body and the result your application expected before recording success.

The task is ready, but the target rejects the request.

Inspect the outgoing request: its URL, every returned header, User-Agent, sec-ch-ua and the proxy selected by SuccessfulProxy.

Try this: Correct any mismatch before requesting another solve. A ready solution does not guarantee downstream acceptance.

Solve returns an error before the target request runs.

Distinguish an API HTTP error from a terminal task failure. A failed task includes errorCode and error.

Try this: Use those details to correct the request rather than retrying unchanged invalid inputs. If you replace Solve with manual polling, stop polling when the task fails.

See API error handling for failures during task creation or solving.

Run your first task.

Start with $5 in workspace credit.

Create a workspace