Get /surveys/{{survey-id}}/previous-page
This functionality is currently released in ALPHA and under testing. BETA release is expected in April 2026.

Example Request

https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/previous-page

The value of environment {{env}} variable depends upon your datacenter. Refer to the Environment page for more details.


Navigates the respondent back to the previous survey page. The response has the same shape as GET /take — it returns the previous page's questions with the answers the respondent previously submitted already embedded in the question JSON. A POST /submit-page must have succeeded at least once before this endpoint can be called.


Send the x-survey-token received from the last POST /submit-page or GET /previous-page or GET /take response. The server returns a refreshed token in the response — always use the latest token on subsequent calls.


Authorization

arrow_rightSession Token — x-survey-token
Name : x-survey-token
required
Location : Request Header
Type : string
Description : Signed session token obtained from the x-survey-token response header of the previous GET /take or POST /submit-page or GET /previous-page call. Echo it back verbatim. The server returns a refreshed token in the response header — always use the latest token on subsequent requests.
arrow_rightSecurity - API Key
Name : api-key
required
Location : Request Header
Type : string

Request Parameters

arrow_rightPath Parameters
survey-id integer
required

Example Code

arrow_rightcURL
Snippet copied successfully.
application/json

curl --location 'https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/previous-page' \
  --header 'Accept: application/json' \
  --header 'api-key: {{api-key}}' \
  --header 'x-survey-token: {{x-survey-token}}'
            
arrow_rightPython
Snippet copied successfully.
application/json

import requests

url = "https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/previous-page"

headers = {
    "Accept": "application/json",
    "api-key": "{{api-key}}",
    "x-survey-token": session_token  #  token from the last GET /take or POST /submit-page response
}

response = requests.get(url, headers=headers)
data = response.json()

#  Refresh the token from the response header
session_token = response.headers.get("x-survey-token")
            
arrow_rightPHP - cURL
Snippet copied successfully.
application/json

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL            => 'https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/previous-page',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HEADER         => true,
    CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST  => 'GET',
    CURLOPT_HTTPHEADER     => array(
        'Accept: application/json',
        'api-key: {{api-key}}',
        'x-survey-token: ' . $sessionToken
    ),
));

$response   = curl_exec($curl);
$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$headersRaw = substr($response, 0, $headerSize);
$body       = substr($response, $headerSize);
curl_close($curl);

// Refresh the session token from the response headers
preg_match('/x-survey-token:\s*(\S+)/i', $headersRaw, $m);
$sessionToken = $m[1] ?? null;

echo $body;
            
arrow_rightJavaScript (fetch)
Snippet copied successfully.
application/json

// sessionToken must be the token received from the last GET /take or POST /submit-page response
const response = await fetch(
    'https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/previous-page',
    {
        method: 'GET',
        headers: {
            'Accept': 'application/json',
            'api-key': '{{api-key}}',
            'x-survey-token': sessionToken
        }
    }
);
const data = await response.json();

// Always refresh the token after each call
sessionToken = response.headers.get('x-survey-token');
            

Responses

arrow_right200 OK — Previous page loaded with pre-filled answers
application/json

// Response header returned by the server (echo this back on the next request):
// x-survey-token: eyJ1dWlkIjoiYWJjMTIzIiwicnMiOjEyMzQ1NiwiaW5zIjoiIiwic2VjIjpbXX0.HMAC_SIGNATURE

{
  "response": {
    "status": "success",
    "meta": {
      "isFinalPage": false,
      "progressPercentage": 25
    },
    "navigation": {
      "previousPageUrl": null,
      "nextPageSubmitUrl": "/a/api/v2/surveys/123456/submit-page"
    },
    "themeConfig": {
      "cssUrls": ["https://cdn.questionpro.com/themes/corporate.css"],
      "jsUrls": []
    },
    "questions": [
      {
        "html": "<div class='qstn-row'>...rendered HTML with previously selected answer highlighted...</div>",
        "json": {
          "id": 10001,
          "type": "U",
          "text": "How satisfied are you with our service?",
          "answers": [
            { "id": 50001, "text": "Very satisfied" },
            { "id": 50002, "text": "Satisfied", "selected": true },
            { "id": 50003, "text": "Neutral" }
          ],
          "formParam": {
            "paramPrefix": "u_",
            "paramIdType": "questionId"
          }
        }
      }
    ]
  },
  "requestID": "7ab12cde-3f45-67gh-89ij-0k1lm2n3o4p5"
}
                
arrow_rightSchema
application/json

// Response header on every call:
// x-survey-token: <signed-token>  — always present; echo back verbatim on the next request

{
  "response": {
    "status": "string — success | error",
    "meta": {
      "isFinalPage": "boolean",
      "progressPercentage": "integer (0–100)"
    },
    "navigation": {
      "previousPageUrl": "string | null — null when this is now the first page",
      "nextPageSubmitUrl": "string — URL to re-submit this page's answers"
    },
    "themeConfig": {
      "cssUrls": "array of string — stylesheet URLs for the survey theme",
      "jsUrls": "array of string — JavaScript URLs for the survey theme"
    },
    "questions": [
      {
        "html": "string | null — pre-rendered HTML with previously selected answers reflected",
        "json": "string — JSON-encoded section object; selected answers are marked with selected: true"
      }
    ]
  },
  "requestID": "string"
}
                
arrow_right400 — No previous page available
application/json

{
    "response": {
     "error": {
         "docs": www.questionpro.com/api/error-codes.html
         "name": "BAD_REQUEST",
         "httpStatusCode": 400,
         "id" : "1000",
         "message": "Invalid URL parameters",
         "resourceUrl":"resource_url"
        }
    }
}
                                
arrow_rightSchema
application/json

{
  "$schema": "http://json-schema.org/draft-06/schema#                                      ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "docs": {
              "type": "string"
            },
            "resourceUrl": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "httpStatusCode": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "docs",
            "resourceUrl",
            "name",
            "id",
            "message",
            "httpStatusCode"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "error"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
                                
arrow_right400 Bad Request — No previous submission exists
application/json

{
  "error": {
    "code": 1002,
    "message": "No previous page to navigate back to."
  },
  "requestID": "7ab12cde-3f45-67gh-89ij-0k1lm2n3o4p5"
}
                
arrow_right400 example
application/json

{
    "response": {
     "error": {
         "docs": www.questionpro.com/api/error-codes.html
         "name": "BAD_REQUEST",
         "httpStatusCode": 400,
         "id" : "1000",
         "message": "Invalid URL parameters",
         "resourceUrl":"resource_url"
        }
    }
}
                                
arrow_rightSchema
application/json

{
  "$schema": "http://json-schema.org/draft-06/schema#                                      ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "docs": {
              "type": "string"
            },
            "resourceUrl": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "httpStatusCode": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "docs",
            "resourceUrl",
            "name",
            "id",
            "message",
            "httpStatusCode"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "error"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
                                
arrow_right401 example
application/json

{
    "response": {
     "error": {
         "docs": www.questionpro.com/api/error-codes.html
         "name": "UNAUTHORIZED",
         "httpStatusCode": 401,
         "id" : "1010",
         "message": "Incorrect API Key",
         "resourceUrl":"resource_url"
        }
    }
}
						
							
arrow_rightSchema
application/json

{
  "$schema": "http://json-schema.org/draft-06/schema#                                      ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "docs": {
              "type": "string"
            },
            "resourceUrl": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "httpStatusCode": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "docs",
            "resourceUrl",
            "name",
            "id",
            "message",
            "httpStatusCode"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "error"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
                                
arrow_right403 example
application/json

{
    "response": {
     "error": {
         "docs": www.questionpro.com/api/error-codes.html
         "name": "FORBIDDEN",
         "httpStatusCode": 403,
         "id" : "1013",
         "message": "The user does not have permission to access the resource",
         "resourceUrl":"resource_url"
        }
    }
}				
							
arrow_rightSchema
application/json

{
  "$schema": "http://json-schema.org/draft-06/schema#                                      ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "docs": {
              "type": "string"
            },
            "resourceUrl": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "httpStatusCode": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "docs",
            "resourceUrl",
            "name",
            "id",
            "message",
            "httpStatusCode"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "error"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
                                
arrow_right404 example
application/json

{
    "response": {
     "error": {
         "docs": www.questionpro.com/api/error-codes.html
         "name": "NOT_FOUND",
         "httpStatusCode": 404,
         "id" : "1040",
         "message": "The resource that you're trying to access doesn't exist",
         "resourceUrl":"resource_url"
        }
    }
}
							
							
arrow_rightSchema
application/json

{
  "$schema": "http://json-schema.org/draft-06/schema#                                      ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "docs": {
              "type": "string"
            },
            "resourceUrl": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "httpStatusCode": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "docs",
            "resourceUrl",
            "name",
            "id",
            "message",
            "httpStatusCode"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "error"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
                                
arrow_right500 example
application/json

{
    "response": {
     "error": {
         "docs": www.questionpro.com/api/error-codes.html
         "name": "INTERNAL_SERVER_ERROR",
         "httpStatusCode": 500,
         "id" : "1026",
         "message": "We are not able to process your request",
         "resourceUrl":"resource_url"
        }
    }
}
							
arrow_rightSchema
application/json

{
  "$schema": "http://json-schema.org/draft-06/schema#                                      ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "docs": {
              "type": "string"
            },
            "resourceUrl": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "httpStatusCode": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "docs",
            "resourceUrl",
            "name",
            "id",
            "message",
            "httpStatusCode"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "error"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
                                

Behaviour Notes

arrow_rightKey Behaviours
The previousPageUrl in the navigation object of GET /take and POST /submit-page points to this endpoint.
previousPageUrl is null when the respondent is on the first page — do not show a Back button in that case.
A 400 is returned if no prior submission exists in session (i.e. the respondent is on the first page and has not submitted anything yet).
If the survey does not allow back navigation, the server returns the current page instead of the previous one — the response will still have status success.
The x-survey-token is refreshed on every call. Always read and store the token from the response header to use on the next request.