Import SQL into your D1 Database
POST/accounts/{account_id}/d1/database/{database_id}/import
Generates a temporary URL for uploading an SQL file to, then instructing the D1 to import it and polling it for status updates. Imports block the D1 for their duration.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Path Parameters
Import SQL into your D1 Database
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/d1/database/$DATABASE_ID/import \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-d '{
"action": "init",
"etag": "etag"
}'{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"at_bookmark": "at_bookmark",
"error": "error",
"filename": "filename",
"messages": [
"string"
],
"result": {
"final_bookmark": "final_bookmark",
"meta": {
"changed_db": true,
"changes": 0,
"duration": 0,
"last_row_id": 0,
"rows_read": 0,
"rows_written": 0,
"served_by_colo": "LHR",
"served_by_primary": true,
"served_by_region": "EEUR",
"size_after": 0,
"timings": {
"sql_duration_ms": 0
}
},
"num_queries": 0
},
"status": "complete",
"success": true,
"type": "import",
"upload_url": "upload_url"
},
"success": true
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"at_bookmark": "at_bookmark",
"error": "error",
"filename": "filename",
"messages": [
"string"
],
"result": {
"final_bookmark": "final_bookmark",
"meta": {
"changed_db": true,
"changes": 0,
"duration": 0,
"last_row_id": 0,
"rows_read": 0,
"rows_written": 0,
"served_by_colo": "LHR",
"served_by_primary": true,
"served_by_region": "EEUR",
"size_after": 0,
"timings": {
"sql_duration_ms": 0
}
},
"num_queries": 0
},
"status": "complete",
"success": true,
"type": "import",
"upload_url": "upload_url"
},
"success": true
}