# Retry failed rows

Re-queue only the failed rows of an import job.

Puts the `failed` rows of the job back in the queue and answers 202. Rows that were created, skipped, or duplicates are not touched. `retried` is the number of rows queued again; when it is 0, `status` is `unchanged`. Fix the cause first (for example create the missing counterparty), since the rows are retried with the same data. Needs the same scopes as creating the job.

## See also

- [Get import job](https://www.invunion.com/knowledge-base/api/get-import-job/) (`GET /api/v1/import-jobs/:id`). Read the failed rows before retrying.

- HTTP method: `POST`
- Path: `/api/v1/import-jobs/:id/retry-failed`
- URL: `https://api.invunion.com/api/v1/import-jobs/:id/retry-failed`
- Required scope: `ingest:write`
- Idempotency-Key header: accepted. See https://www.invunion.com/knowledge-base/api/idempotency/
- HTML docs: https://www.invunion.com/knowledge-base/api/retry-import-job/
- Markdown docs: https://www.invunion.com/knowledge-base/api/retry-import-job.md

## Path parameters

| Name | Type | Required | Description | Allowed values | Example |
| --- | --- | --- | --- | --- | --- |
| `id` | string, no maximum | required | Import job UUID, from Create import job or List import jobs. |  | `6a4deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d` |



## Errors

| Error | HTTP code | Description |
| --- | --- | --- |
| `Missing Bearer token` | `401` | The Authorization header is missing or is not a Bearer token. |
| `Invalid or revoked API key` | `401` | The API key is unknown, malformed, expired, or has been revoked. |
| `API key is missing scope ingest:write` | `403` | The key does not include ingest:write. A write scope does not imply the matching read scope. |
| `Too many requests, please try again later` | `429` | More than 100 requests in one minute from this API key or IP address. Wait for the Retry-After header (seconds) and retry. |
| `API key is missing scope …` | `403` | Besides ingest:write, the key needs the write scope of the entity: ingest:write for transactions, invoices:write, counterparties:write, or payment_methods:write. code is missing_scope. |
| `Invalid job id` | `400` | The path is not a UUID. |
| `Import job not found` | `404` | No import job with this UUID exists in the authenticated tenant. |
| `Internal server error` | `500` | Unexpected server error. The JSON body includes correlationId. Retry with backoff. |
| `Idempotency-Key must be 8-255 characters: letters, digits, ".", "_", ":" or "-".` | `400` | The Idempotency-Key header is present but malformed. |
| `A request with this Idempotency-Key is still being processed.` | `409` | The first request with this key has not finished. Retry after it completes. code is idempotency_in_progress. |
| `This Idempotency-Key was already used with a different request body.` | `422` | Send a new key for a different request. code is idempotency_key_reuse. |

## Request (curl)

```bash
curl --request POST \
  --url https://api.invunion.com/api/v1/import-jobs/6a4deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d/retry-failed \
  --header 'accept: application/json' \
  --header 'authorization: Bearer uk_live_YOUR_API_KEY'
```

## Request (Python)

```python
import requests

url = "https://api.invunion.com/api/v1/import-jobs/6a4deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d/retry-failed"
headers = {
    "Accept": "application/json",
    "Authorization": "Bearer uk_live_YOUR_API_KEY",
}
response = requests.post(url, headers=headers)
print(response.json())
```

## Request (Ruby)

```ruby
require 'net/http'
require 'json'
require 'uri'

uri = URI("https://api.invunion.com/api/v1/import-jobs/6a4deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d/retry-failed")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Accept'] = 'application/json'
request['Authorization'] = 'Bearer uk_live_YOUR_API_KEY'
response = http.request(request)
puts response.body
```

## Request (JavaScript)

```javascript
const response = await fetch("https://api.invunion.com/api/v1/import-jobs/6a4deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d/retry-failed", {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer uk_live_YOUR_API_KEY"
  },
});
const data = await response.json();
```

## Request (Go)

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, err := http.NewRequest("POST", "https://api.invunion.com/api/v1/import-jobs/6a4deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d/retry-failed", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Accept", "application/json")
	req.Header.Set("Authorization", "Bearer uk_live_YOUR_API_KEY")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```

## Request (Node)

```javascript
const response = await fetch("https://api.invunion.com/api/v1/import-jobs/6a4deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d/retry-failed", {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer uk_live_YOUR_API_KEY"
  },
});
console.log(await response.json());
```

## Success (202)

```json
{
  "success": true,
  "data": {
    "jobId": "6a4deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
    "retried": 1,
    "status": "processing"
  }
}
```
