# POST `/merchant/v1/resource-executions/{resource_execution_id}/complete`

[Documentation page](/api-reference/resources/resources.complete_execution)

## Summary

Complete a free resource execution

## Description

Retain safe response metadata for allowed work that did not create a payment transaction.

## Security requirements

```json
[
  {
    "OrganizationApiKeyAuth": []
  }
]
```

## Operation parameters

### path `resource_execution_id`

```json
{
  "description": "Server-issued resource execution identifier.",
  "example": "rex_00000000000070008000000000000000",
  "in": "path",
  "name": "resource_execution_id",
  "required": true,
  "schema": {
    "description": "Server-issued resource execution identifier.",
    "examples": [
      "rex_00000000000070008000000000000000"
    ],
    "pattern": "^rex_[0-9a-f]{12}7[0-9a-f]{3}[89ab][0-9a-f]{15}$",
    "title": "Resource Execution Id",
    "type": "string",
    "x-recuut-public-id-prefix": "rex"
  }
}
```

## Request body

```json
{
  "content": {
    "application/json": {
      "examples": {
        "complete": {
          "summary": "Retain a free resource response",
          "value": {
            "resource_execution": {
              "duration_ms": 84,
              "response_content_type": "application/json",
              "response_size_bytes": 312,
              "response_status": 200
            },
            "revision_id": "acr_00000000000070008000000000000000"
          }
        }
      },
      "schema": {
        "$ref": "#/components/schemas/ResourceExecutionCompleteRequest"
      }
    }
  },
  "required": true
}
```

## Responses

### 200

```json
{
  "content": {
    "application/json": {
      "examples": {
        "completed": {
          "summary": "Resource execution completed",
          "value": {
            "resource_execution_id": "rex_00000000000070008000000000000000"
          }
        }
      },
      "schema": {
        "$ref": "#/components/schemas/ResourceExecutionCompleteResult"
      }
    }
  },
  "description": "OK"
}
```

### 400

```json
{
  "content": {
    "application/json": {
      "examples": {
        "invalid_request": {
          "summary": "Invalid request",
          "value": {
            "code": "invalid_request",
            "message": "The request is invalid."
          }
        }
      },
      "schema": {
        "additionalProperties": false,
        "description": "Error returned for this endpoint and HTTP status.",
        "properties": {
          "code": {
            "const": "invalid_request",
            "description": "Stable error code your app can check.",
            "type": "string"
          },
          "message": {
            "description": "Short explanation of what went wrong.",
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      }
    }
  },
  "description": "Bad Request"
}
```

### 401

```json
{
  "content": {
    "application/json": {
      "examples": {
        "unauthenticated": {
          "summary": "API key required",
          "value": {
            "code": "unauthenticated",
            "message": "A valid Recuut API key is required."
          }
        }
      },
      "schema": {
        "additionalProperties": false,
        "description": "Error returned for this endpoint and HTTP status.",
        "properties": {
          "code": {
            "const": "unauthenticated",
            "description": "Stable error code your app can check.",
            "type": "string"
          },
          "message": {
            "description": "Short explanation of what went wrong.",
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      }
    }
  },
  "description": "Unauthorized"
}
```

### 403

```json
{
  "content": {
    "application/json": {
      "examples": {
        "forbidden": {
          "summary": "Capability denied",
          "value": {
            "code": "forbidden",
            "message": "This API key does not allow this operation."
          }
        }
      },
      "schema": {
        "additionalProperties": false,
        "description": "Error returned for this endpoint and HTTP status.",
        "properties": {
          "code": {
            "const": "forbidden",
            "description": "Stable error code your app can check.",
            "type": "string"
          },
          "message": {
            "description": "Short explanation of what went wrong.",
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      }
    }
  },
  "description": "Forbidden"
}
```

### 404

```json
{
  "content": {
    "application/json": {
      "examples": {
        "resource_execution_not_found": {
          "summary": "Resource execution not found",
          "value": {
            "code": "resource_execution_not_found",
            "message": "Resource execution not found."
          }
        }
      },
      "schema": {
        "additionalProperties": false,
        "description": "Error returned for this endpoint and HTTP status.",
        "properties": {
          "code": {
            "const": "resource_execution_not_found",
            "description": "Stable error code your app can check.",
            "type": "string"
          },
          "message": {
            "description": "Short explanation of what went wrong.",
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      }
    }
  },
  "description": "Not Found"
}
```

### 409

```json
{
  "content": {
    "application/json": {
      "examples": {
        "resource_execution_conflict": {
          "summary": "Resource execution conflict",
          "value": {
            "code": "resource_execution_conflict",
            "message": "Resource response metadata conflicts with the accepted response."
          }
        },
        "revision_mismatch": {
          "summary": "Revision mismatch",
          "value": {
            "code": "revision_mismatch",
            "message": "The completion revision does not match the resource execution."
          }
        }
      },
      "schema": {
        "additionalProperties": false,
        "description": "Error returned for this endpoint and HTTP status.",
        "properties": {
          "code": {
            "description": "Stable error code your app can check.",
            "enum": [
              "resource_execution_conflict",
              "revision_mismatch"
            ],
            "type": "string"
          },
          "message": {
            "description": "Short explanation of what went wrong.",
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      }
    }
  },
  "description": "Conflict"
}
```

### 422

```json
{
  "content": {
    "application/json": {
      "examples": {
        "invalid_request": {
          "summary": "Invalid request",
          "value": {
            "code": "invalid_request",
            "message": "The request is invalid."
          }
        }
      },
      "schema": {
        "additionalProperties": false,
        "description": "Error returned for this endpoint and HTTP status.",
        "properties": {
          "code": {
            "const": "invalid_request",
            "description": "Stable error code your app can check.",
            "type": "string"
          },
          "message": {
            "description": "Short explanation of what went wrong.",
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      }
    }
  },
  "description": "Unprocessable Content"
}
```

### 500

```json
{
  "content": {
    "application/json": {
      "examples": {
        "internal_error": {
          "summary": "Internal error",
          "value": {
            "code": "internal_error",
            "message": "The request could not be completed."
          }
        }
      },
      "schema": {
        "additionalProperties": false,
        "description": "Error returned for this endpoint and HTTP status.",
        "properties": {
          "code": {
            "const": "internal_error",
            "description": "Stable error code your app can check.",
            "type": "string"
          },
          "message": {
            "description": "Short explanation of what went wrong.",
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      }
    }
  },
  "description": "Internal Server Error"
}
```

## First-party examples

### cURL

```json
{
  "label": "cURL",
  "lang": "shell",
  "source": "curl --request POST \\\n  --url \"$RECUUT_API_URL/merchant/v1/resource-executions/rex_00000000000070008000000000000000/complete\" \\\n  --header \"Authorization: Bearer $RECUUT_API_KEY\" \\\n  --header 'Content-Type: application/json' \\\n  --data '{\"resource_execution\":{\"duration_ms\":84,\"response_content_type\":\"application/json\",\"response_size_bytes\":312,\"response_status\":200},\"revision_id\":\"acr_00000000000070008000000000000000\"}'\n",
  "x-recuut-request-example": "complete"
}
```

```shell
curl --request POST \
  --url "$RECUUT_API_URL/merchant/v1/resource-executions/rex_00000000000070008000000000000000/complete" \
  --header "Authorization: Bearer $RECUUT_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{"resource_execution":{"duration_ms":84,"response_content_type":"application/json","response_size_bytes":312,"response_status":200},"revision_id":"acr_00000000000070008000000000000000"}'

```

## Canonical operation

```json
{
  "description": "Retain safe response metadata for allowed work that did not create a payment transaction.",
  "operationId": "resources.complete_execution",
  "parameters": [
    {
      "description": "Server-issued resource execution identifier.",
      "example": "rex_00000000000070008000000000000000",
      "in": "path",
      "name": "resource_execution_id",
      "required": true,
      "schema": {
        "description": "Server-issued resource execution identifier.",
        "examples": [
          "rex_00000000000070008000000000000000"
        ],
        "pattern": "^rex_[0-9a-f]{12}7[0-9a-f]{3}[89ab][0-9a-f]{15}$",
        "title": "Resource Execution Id",
        "type": "string",
        "x-recuut-public-id-prefix": "rex"
      }
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "examples": {
          "complete": {
            "summary": "Retain a free resource response",
            "value": {
              "resource_execution": {
                "duration_ms": 84,
                "response_content_type": "application/json",
                "response_size_bytes": 312,
                "response_status": 200
              },
              "revision_id": "acr_00000000000070008000000000000000"
            }
          }
        },
        "schema": {
          "$ref": "#/components/schemas/ResourceExecutionCompleteRequest"
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "examples": {
            "completed": {
              "summary": "Resource execution completed",
              "value": {
                "resource_execution_id": "rex_00000000000070008000000000000000"
              }
            }
          },
          "schema": {
            "$ref": "#/components/schemas/ResourceExecutionCompleteResult"
          }
        }
      },
      "description": "OK"
    },
    "400": {
      "content": {
        "application/json": {
          "examples": {
            "invalid_request": {
              "summary": "Invalid request",
              "value": {
                "code": "invalid_request",
                "message": "The request is invalid."
              }
            }
          },
          "schema": {
            "additionalProperties": false,
            "description": "Error returned for this endpoint and HTTP status.",
            "properties": {
              "code": {
                "const": "invalid_request",
                "description": "Stable error code your app can check.",
                "type": "string"
              },
              "message": {
                "description": "Short explanation of what went wrong.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        }
      },
      "description": "Bad Request"
    },
    "401": {
      "content": {
        "application/json": {
          "examples": {
            "unauthenticated": {
              "summary": "API key required",
              "value": {
                "code": "unauthenticated",
                "message": "A valid Recuut API key is required."
              }
            }
          },
          "schema": {
            "additionalProperties": false,
            "description": "Error returned for this endpoint and HTTP status.",
            "properties": {
              "code": {
                "const": "unauthenticated",
                "description": "Stable error code your app can check.",
                "type": "string"
              },
              "message": {
                "description": "Short explanation of what went wrong.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        }
      },
      "description": "Unauthorized"
    },
    "403": {
      "content": {
        "application/json": {
          "examples": {
            "forbidden": {
              "summary": "Capability denied",
              "value": {
                "code": "forbidden",
                "message": "This API key does not allow this operation."
              }
            }
          },
          "schema": {
            "additionalProperties": false,
            "description": "Error returned for this endpoint and HTTP status.",
            "properties": {
              "code": {
                "const": "forbidden",
                "description": "Stable error code your app can check.",
                "type": "string"
              },
              "message": {
                "description": "Short explanation of what went wrong.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        }
      },
      "description": "Forbidden"
    },
    "404": {
      "content": {
        "application/json": {
          "examples": {
            "resource_execution_not_found": {
              "summary": "Resource execution not found",
              "value": {
                "code": "resource_execution_not_found",
                "message": "Resource execution not found."
              }
            }
          },
          "schema": {
            "additionalProperties": false,
            "description": "Error returned for this endpoint and HTTP status.",
            "properties": {
              "code": {
                "const": "resource_execution_not_found",
                "description": "Stable error code your app can check.",
                "type": "string"
              },
              "message": {
                "description": "Short explanation of what went wrong.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        }
      },
      "description": "Not Found"
    },
    "409": {
      "content": {
        "application/json": {
          "examples": {
            "resource_execution_conflict": {
              "summary": "Resource execution conflict",
              "value": {
                "code": "resource_execution_conflict",
                "message": "Resource response metadata conflicts with the accepted response."
              }
            },
            "revision_mismatch": {
              "summary": "Revision mismatch",
              "value": {
                "code": "revision_mismatch",
                "message": "The completion revision does not match the resource execution."
              }
            }
          },
          "schema": {
            "additionalProperties": false,
            "description": "Error returned for this endpoint and HTTP status.",
            "properties": {
              "code": {
                "description": "Stable error code your app can check.",
                "enum": [
                  "resource_execution_conflict",
                  "revision_mismatch"
                ],
                "type": "string"
              },
              "message": {
                "description": "Short explanation of what went wrong.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        }
      },
      "description": "Conflict"
    },
    "422": {
      "content": {
        "application/json": {
          "examples": {
            "invalid_request": {
              "summary": "Invalid request",
              "value": {
                "code": "invalid_request",
                "message": "The request is invalid."
              }
            }
          },
          "schema": {
            "additionalProperties": false,
            "description": "Error returned for this endpoint and HTTP status.",
            "properties": {
              "code": {
                "const": "invalid_request",
                "description": "Stable error code your app can check.",
                "type": "string"
              },
              "message": {
                "description": "Short explanation of what went wrong.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        }
      },
      "description": "Unprocessable Content"
    },
    "500": {
      "content": {
        "application/json": {
          "examples": {
            "internal_error": {
              "summary": "Internal error",
              "value": {
                "code": "internal_error",
                "message": "The request could not be completed."
              }
            }
          },
          "schema": {
            "additionalProperties": false,
            "description": "Error returned for this endpoint and HTTP status.",
            "properties": {
              "code": {
                "const": "internal_error",
                "description": "Stable error code your app can check.",
                "type": "string"
              },
              "message": {
                "description": "Short explanation of what went wrong.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        }
      },
      "description": "Internal Server Error"
    }
  },
  "security": [
    {
      "OrganizationApiKeyAuth": []
    }
  ],
  "summary": "Complete a free resource execution",
  "tags": [
    "resources"
  ],
  "x-codeSamples": [
    {
      "label": "cURL",
      "lang": "shell",
      "source": "curl --request POST \\\n  --url \"$RECUUT_API_URL/merchant/v1/resource-executions/rex_00000000000070008000000000000000/complete\" \\\n  --header \"Authorization: Bearer $RECUUT_API_KEY\" \\\n  --header 'Content-Type: application/json' \\\n  --data '{\"resource_execution\":{\"duration_ms\":84,\"response_content_type\":\"application/json\",\"response_size_bytes\":312,\"response_status\":200},\"revision_id\":\"acr_00000000000070008000000000000000\"}'\n",
      "x-recuut-request-example": "complete"
    }
  ]
}
```
