Skip to content
Constaia

WordPress

Validate documents with AI in WordPress

A minimal plugin adds the route that receives documents, with the key stored in your WordPress configuration.

Installation

composer require constaia/constaia-php

The safe pattern

The browser or app never sees your secret key. The file goes to your server, your server calls Constaia and returns the result. If you do not have a server, use the widget with a publishable key.

Full guide
wp-content/plugins/constaia-verify/constaia-verify.php
<?php
/** Plugin Name: Constaia Verify */

add_action('rest_api_init', function () {
    register_rest_route('constaia/v1', '/verify', [
        'methods' => 'POST',
        'permission_callback' => fn () => is_user_logged_in(),
        'callback' => function (WP_REST_Request $request) {
            $files = $request->get_file_params();
            $client = new \Constaia\Client(CONSTAIA_API_KEY); // define() it in wp-config.php
            $file = $files['file'];
            $analysis = $client->analyze(['base64' => base64_encode(file_get_contents($file['tmp_name'])), 'filename' => $file['name']], [
                'expect' => 'es_dni',
                'checks' => ['not_expired' => true],
            ]);
            return ['status' => $analysis->verdictStatus()];
        },
    ]);
});

One call. An answer you can act on.

  1. 01

    Send the document and what you expect

    A photo, screenshot or PDF. Tell us which document you expect and the rules it must meet: not expired, issued in the last 60 days, in this person's name.

  2. 02

    We read, classify and check

    Text reading, AI classification and fixed checks: PDF417 barcodes, machine-readable zones, ABA routing numbers, dates and totals.

  3. 03

    Get the verdict and the file is deleted

    Valid, invalid or review, with the reasons in your language. By default, the file is deleted when the analysis ends unless it needs review.

And for the record…

Create your free account and validate your first document in five minutes. No credit card required.