> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuro-tech.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a contract with the Agent API

> Propose a template and create a contract instance over HTTP

Use the Agent API when a web or backend application needs to work with contracts. The API does not require access to the Neuron source code.

<Warning>
  This page covers template proposal and contract creation, not the complete agreement lifecycle. Before sending a proposal, ask the Neuron operator which transport and XML namespace the deployment supports.
</Warning>

## Before you start

You need:

* the Neuron host;
* an Agent API account and JWT from the [Agent API quickstart](/neuron-api/quickstart);
* a current approved Legal Identity for operations that require one;
* valid template XML, normally prepared in [LegalLab](/contracts/legallab-quickstart).

Set the examples' placeholders without committing credentials:

```bash theme={null}
export NEURON_HOST="neuron.example.com"
export NEURON_JWT="<JWT>"
```

## Path A: propose your template

Base64-encode the complete UTF-8 XML file as one string:

```bash theme={null}
TEMPLATE_BASE64=$(base64 < MyTemplate.xml | tr -d '\n')
```

Submit it:

```bash theme={null}
curl --fail-with-body \
  -X POST "https://${NEURON_HOST}/Agent/Legal/ProposeTemplate" \
  -H "Authorization: Bearer ${NEURON_JWT}" \
  -H "Content-Type: application/json" \
  -d "{\"templateBase64\":\"${TEMPLATE_BASE64}\"}"
```

The response contains `Template`; record its `id`. A proposed template must be approved before it can create instances.

## Path B: create from an approved template

If the operator has already supplied an approved template ID, you can begin here:

```bash theme={null}
curl --fail-with-body \
  -X POST "https://${NEURON_HOST}/Agent/Legal/CreateContract" \
  -H "Authorization: Bearer ${NEURON_JWT}" \
  -H "Content-Type: application/json" \
  -d '{
    "templateId": "<APPROVED_TEMPLATE_ID>",
    "visibility": "CreatorAndParts",
    "Parts": [],
    "Parameters": []
  }'
```

Replace `Parts` and `Parameters` with the names and value types defined by that template. The response contains the created `Contract`.

<Note>
  An empty `Parts` or `Parameters` array works only when the selected template does not require those values. The template—not this endpoint—defines what must be supplied.
</Note>

## Continue after creation

* Retrieve the returned contract with `POST /Agent/Legal/GetContract`.
* Present the exact returned human-readable text before signing.
* Use `POST /Agent/Legal/SignContract` only after the signer, role, content, key, nonce, and signatures have been confirmed.
* Do not implement `POST /Agent/Legal/SendProposal` from this page. Obtain the supported request format from the Neuron operator first.

See the [contract API reference](/neuron-api/api-reference/contracts/overview) for request fields and responses.
