The answer depends on what you mean by the longest word, but regardless of your definition the longest word isn't superextraordinarísimo, the 22-letter word once listed in the famous recordbook and the word most often cited as the longest in the language. (It means "most superextraordinary.")
The designation of superextraordinarísimo seems arbitrary at best. For one thing, the word isn't in real use. As of this writing, a Google search shows not a single instance where the word was used on a Spanish-language Web site except on pages listing what they called the longest Spanish words. And superextraordinarísimo has two other strikes against it: If one is going to create words by adding prefixes and suffixes, one could just as well make a 27-letter word by using the adverbial form, superextraordinarísimamente. Or one could just as easily use longer root words, ending up with words such as superespectacularísimamente ("most superspectacularly"). But again they're hypothetical words rather than ones that get legitimate use.
A better choice for a 22-letter word is esternocleidomastoideo, the name of a certain neck muscle. It can be found in Spanish-language medical texts.
But we can do better without coining words. The longest words in real use appear to be two 23-letter beauties: anticonstitucionalmente ("unconstitutionally") and electroencefalografista ("electroencephalograph technician"). Since the latter is a noun, it can be made a 24-letter plural, electroencefalografistas, my designation as the longest legitimate Spanish word. And it indeed is a word in real use not everyday use, but you can find it listed in some phone directories, for example.
By coining cognates of some especially long English words, it would be possible to come up with longer words still. For example, some medical words and names of certain chemicals in English top 30 letters, and the longest English word listed in an accepted dictionary is reported to be "pneumonoultramicroscopicsilicovolcanokoniosis," a type of lung disease. Conversion of the word to Spanish, which is made easy by the fact that all the roots have Spanish cognates, presumably would be neumonoultramicroscopicosiliciovolcanconiosis at 45 letters, or something similar. But such words would probably be considered spurious rather than legitimate Spanish.