> For the complete documentation index, see [llms.txt](https://docs.elentra.org/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.elentra.org/api/automated-testing/functional-tests/testing-http-verbs/post-put-delete-requests.md).

# POST / PUT / DELETE Requests

#### POST / PUT / DELETE Requests

When calling a POST / PUT / DELETE method, three pieces of information are required:

1. The URL (This could also contain the query parameters)
2. The authentication token
3. The payload

{% hint style="warning" %}
POST, PUT and DELETE requests modify the original seed data that might affect other tests. Use [annotations](/api/automated-testing/functional-tests/annotations.md) to restore the data to the original state before the test was executed.&#x20;
{% endhint %}

{% hint style="info" %}
These requirements also apply to PATCH requests.
{% endhint %}

**POST Example:**

```php
/**
 * Test that the route /user/role returns 201
 *
 * @transaction auth
 * @test
 * @return void
 */
public function user_post_method_user_role_returns_201(): void
{
  $this->actingAsAdmin()
       ->authenticate()
       ->post('/user/role', [
          'organisation_id' => '1',
          'access_id' => '1',
       ]);
}
```

1. The URL in this example is `/user/role`
2. `authenticate()` authenticates the token
3. The third piece of information is the payload.

**PUT Example:**

<pre class="language-php"><code class="lang-php"><strong>$this->actingAsAdmin()
</strong>     ->authenticate()
     ->put('/user/mobilenumber', [
          "number" => "1555".rand(100000,999999)
     ])
</code></pre>

1. The URL in this example is `/user/mobilenumber`
2. `authenticate()` authenticates the token
3. The third piece of information is the payload.

**DELETE Example:**

```php
$this->actingAsAdmin()
     ->authenticate()
     ->delete('/courses/1', []);
```

1. The URL in this example is `/courses/1`
2. `authenticate()` authenticates the token
3. The third piece of information is the payload.

{% hint style="warning" %}
Even if there is no data, pass an empty array otherwise the response will be `403 forbidden`.
{% endhint %}
