> For the complete documentation index, see [llms.txt](https://docs.symm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.symm.io/trader-documentation/building-a-trading-bot/part-1-one-time-on-chain-setup/delegate-the-tpsl-bot.md).

# Delegate the TPSL bot

**Why.** This is separate from delegating the session key. The conditional-orders handler (the service that holds your TP/SL orders and fires them when triggers hit) also checks that *its own* operator address is authorized on your sub-account, not just your session key. If only the session-key delegation ran, the TP/SL endpoint returns `"parent subaccount has not delegated required access to COH for selectors=REQUEST_TO_CLOSE_POSITION"` even though the session key is fine. The bot needs permission to execute closes on your behalf when a trigger fires.

**Signed by.** Owner EOA, again on the InstantLayer's [`grantDelegation`](https://intent.symmscan.com/inspector/hyperevm/instant-layer?method=0xfd7f4c5e).

**`DelegationInfo`:**

* `account`: `(subAccount, isPartyB=false)`
* `delegatedSigner`: `<TPSL bot operator address>` (the deployment's TPSL bot operator)
* `selectors`: four entries: `0x501e891f` (real `requestToClosePosition`), `0xeaa31b19` (Conditional Order Handler's ID), `0xee9ef781` (`requestToClosePosition` overload that takes a `upnlSig`), and `0x00000001`. The COH probes more than one of these depending on the position state, so granting them all is the path of least surprise.
* `expiryTimestamp`: same as the session key's expiry.

So per session refresh you do *two* `grantDelegation` calls: one for the session key with five selectors, one for the bot operator with four selectors. Same EOA signs both.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.symm.io/trader-documentation/building-a-trading-bot/part-1-one-time-on-chain-setup/delegate-the-tpsl-bot.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
